From: Dave Hart Date: Sat, 16 Oct 2010 04:02:17 +0000 (+0000) Subject: min/max confusion in ntpsnmpd change X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ceb6ce93ca3fb9119795e7305d8a6709a0405b2;p=thirdparty%2Fntp.git min/max confusion in ntpsnmpd change bk: 4cb923c988vlcvV3nkvpgBDi0KOFug --- diff --git a/ntpsnmpd/ntpSnmpSubagentObject.c b/ntpsnmpd/ntpSnmpSubagentObject.c index f6175d56e9..57b10ba49b 100644 --- a/ntpsnmpd/ntpSnmpSubagentObject.c +++ b/ntpsnmpd/ntpSnmpSubagentObject.c @@ -171,6 +171,9 @@ ntpsnmpd_cut_string( int l; size_t str_cnt; + if (maxsize < 1) + return 0; + str_cnt = strlen(string); j = 0; memset(dest, 0, maxsize); @@ -182,7 +185,7 @@ ntpsnmpd_cut_string( else if (l == fieldnumber && j < maxsize) dest[j++] = string[i]; } - j = max(j, maxsize - 1); + j = min(j, maxsize - 1); dest[j] = '\0'; return j;