]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix string termination in snmplib
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 4 Jun 2013 02:59:47 +0000 (20:59 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 4 Jun 2013 02:59:47 +0000 (20:59 -0600)
strncpy() does not null-terminate if the source string is larger or equal
to the destination buffer length.

 Detected by Coverity Scan. Issue 1025738.

snmplib/parse.c

index 352af377a486f00eff5389b57c8785de4e0159b8..4cc978e2499f265e2f3c7d6e54be475152ffda54 100644 (file)
@@ -690,8 +690,8 @@ parse_objectid(FILE *fp, char *name) {
          */
         if (count == (length - 2)) {
             if (op->label) {
-                strncpy(np->parent, op->label, sizeof(np->parent));
-                strncpy(np->label, name, sizeof(np->label));
+                strncpy(np->parent, op->label, sizeof(np->parent)-1);
+                strncpy(np->label, name, sizeof(np->label)-1);
                 if (nop->subid != -1)
                     np->subid = nop->subid;
                 else