Fix subnet-up/down scripts being called with an empty SUBNET.
[tinc] / src / subnet.c
index bc66fec..daefc2f 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
                        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
                        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 {
                        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
                        // 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
                        if(weight)
                                *weight++ = 0;
                        else