]> git.meshlink.io Git - meshlink/commitdiff
Fix subnet-up/down scripts being called with an empty SUBNET.
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 22 Jan 2010 20:47:26 +0000 (21:47 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 22 Jan 2010 20:47:26 +0000 (21:47 +0100)
Commit 052ff8b2c598358d1c5febaa9f9f5fc5d384cfd3 contained a bug that causes
scripts to be called with an empty, or possibly corrupted SUBNET variable when
a Subnet is added or removed while the owner is still online. In router mode,
this normally does not happen, but in switch mode this is normal.

src/subnet.c

index bc66fecccdf69ab2d1dfaa5151f1484254adab96..daefc2f5a2390e7ff34eda51a83df8a23e4c9c76 100644 (file)
@@ -478,7 +478,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
                        if(!net2str(netstr, sizeof netstr, subnet))
                                continue;
                        // Strip the weight from the subnet, and put it in its own environment variable
-                       char *weight = strchr(netstr + 7, '#');
+                       char *weight = strchr(netstr, '#');
                        if(weight)
                                *weight++ = 0;
                        else
@@ -495,9 +495,9 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
                        execute_script(name, envp);
                }
        } else {
-               if(net2str(netstr + 7, sizeof netstr - 7, subnet)) {
+               if(net2str(netstr, sizeof netstr, subnet)) {
                        // Strip the weight from the subnet, and put it in its own environment variable
-                       char *weight = strchr(netstr + 7, '#');
+                       char *weight = strchr(netstr, '#');
                        if(weight)
                                *weight++ = 0;
                        else