From 5d194b9f8767390d9fb1170554a8b6928214957a Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 22 Jan 2010 21:47:26 +0100 Subject: [PATCH] Fix subnet-up/down scripts being called with an empty SUBNET. 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subnet.c b/src/subnet.c index bc66fecc..daefc2f5 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -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 -- 2.20.1