X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsubnet.c;h=b8da09275295129120c230164fb1855ebdb21722;hb=refs%2Fheads%2F1.1-threads;hp=8bc8fce89efdc5040f6ba1c04c27b6d157d7c917;hpb=d6c50eb73ad49bd2eac67214995dff76b7a20661;p=tinc diff --git a/src/subnet.c b/src/subnet.c index 8bc8fce8..b8da0927 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -1,6 +1,6 @@ /* subnet.c -- handle subnet lookups and lists - Copyright (C) 2000-2009 Guus Sliepen , + Copyright (C) 2000-2010 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -469,6 +469,8 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { // 4 and 5 are reserved for SUBNET and WEIGHT xasprintf(&envp[6], "REMOTEADDRESS=%s", address); xasprintf(&envp[7], "REMOTEPORT=%s", port); + free(address); + free(port); } name = up ? "subnet-up" : "subnet-down"; @@ -479,7 +481,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 @@ -496,9 +498,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 @@ -512,7 +514,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { } } - for(i = 0; envp[i] && i < 9; i++) + for(i = 0; envp[i] && i < 8; i++) free(envp[i]); }