]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
min/max confusion in ntpsnmpd change
authorDave Hart <hart@ntp.org>
Sat, 16 Oct 2010 04:02:17 +0000 (04:02 +0000)
committerDave Hart <hart@ntp.org>
Sat, 16 Oct 2010 04:02:17 +0000 (04:02 +0000)
bk: 4cb923c988vlcvV3nkvpgBDi0KOFug

ntpsnmpd/ntpSnmpSubagentObject.c

index f6175d56e9713e1e4858f73f1cb6afd3a2ee796b..57b10ba49b0e9915a34f427a8e4400f1279660c9 100644 (file)
@@ -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;