diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2008-03-29 18:56:44 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2008-03-29 18:56:44 +0000 |
commit | 2d273ccbf7aa524dbfecb1c35c3441e50374ac05 (patch) | |
tree | 115d2b36daf7b009385cbc651836185a55819fb4 /sbin/ifconfig/ifconfig.c | |
parent | 83316508e2fae3b8d8e394ac1efacbf618cba949 (diff) |
fix a free(NULL) in setcarp_nodes().
ok mpf@, chl@
"i agree with the diagnosis" oga@
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index addce6ad612..c4d80c3c16f 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.193 2008/02/05 22:57:30 mpf Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.194 2008/03/29 18:56:43 damien Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -3089,7 +3089,7 @@ unsetcarpdev(const char *val, int d) void setcarp_nodes(const char *val, int d) { - char *str; + char *optlist, *str; int i; struct carpreq carpr; @@ -3102,11 +3102,12 @@ setcarp_nodes(const char *val, int d) bzero(carpr.carpr_vhids, sizeof(carpr.carpr_vhids)); bzero(carpr.carpr_advskews, sizeof(carpr.carpr_advskews)); - str = strdup(val); - if (str == NULL) + optlist = strdup(val); + if (optlist == NULL) err(1, "strdup"); - for (i = 0; (str = strtok(str, ",")) != NULL; str = NULL) { + str = strtok(optlist, ","); + for (i = 0; str != NULL; i++) { u_int vhid, advskew; if (i > CARP_MAXNODES) errx(1, "too many carp nodes"); @@ -3120,9 +3121,9 @@ setcarp_nodes(const char *val, int d) carpr.carpr_vhids[i] = vhid; carpr.carpr_advskews[i] = advskew; - i++; + str = strtok(NULL, ","); } - free(str); + free(optlist); if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1) err(1, "SIOCSVH"); |