From: Guus Sliepen Date: Fri, 22 Jan 2010 20:47:26 +0000 (+0100) Subject: Fix subnet-up/down scripts being called with an empty SUBNET. X-Git-Tag: release-1.0.12~8 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=5d194b9f8767390d9fb1170554a8b6928214957a;ds=sidebyside 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. --- 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