From 7ef7fa8a8db0774a2f75b76d0bda96022b0e10e9 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Wed, 27 Jul 2011 00:37:11 -0400 Subject: [PATCH] Fix the return value of ifchd_cmd_str() and correct its length check. --- ndhc/ifchange.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndhc/ifchange.c b/ndhc/ifchange.c index fc004d0..e1d7a6b 100644 --- a/ndhc/ifchange.c +++ b/ndhc/ifchange.c @@ -121,12 +121,12 @@ static int ifchd_cmd_str(char *buf, size_t buflen, char *optname, { char *obuf = buf; buf += snprintf(buf, buflen, "%s:", optname); - if (buflen < optlen + 1) + if (buflen < (buf - obuf) + optlen + 2) return -1; memcpy(buf, optdata, optlen); buf[optlen] = ':'; buf[optlen+1] = '\0'; - return (buf - obuf) + optlen; + return (buf - obuf) + optlen + 1; } #define IFCHD_SW_CMD(x, y) case DCODE_##x: \