From e6b09a1ac7607b4a5b91198a650e65b6b076654e Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Thu, 23 May 2013 22:38:33 -0600 Subject: [PATCH] Fix buffer null termination strncpy() does not ensure a buffer is nul-terminated if the source is the same length or longer than the destination buffer. Detected by Coverity Scan. Issue 1025738. --- snmplib/parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snmplib/parse.c b/snmplib/parse.c index 352af377a4..92c6a67e97 100644 --- a/snmplib/parse.c +++ b/snmplib/parse.c @@ -691,7 +691,9 @@ parse_objectid(FILE *fp, char *name) { if (count == (length - 2)) { if (op->label) { strncpy(np->parent, op->label, sizeof(np->parent)); + np->parent[sizeof(np->parent-1)] = '\0'; strncpy(np->label, name, sizeof(np->label)); + np->label[sizeof(np->label-1)] = '\0'; if (nop->subid != -1) np->subid = nop->subid; else -- 2.47.2