summaryrefslogtreecommitdiffstats
path: root/contrib/bsnmp/snmpd/main.c
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-01-13 09:04:26 +0000
committerngie <ngie@FreeBSD.org>2017-01-13 09:04:26 +0000
commit0d1d9b78d55a52a685b8c7789982a01450ecf8e3 (patch)
tree975118d083ad109f72d8f6dcd9ee60959b387be1 /contrib/bsnmp/snmpd/main.c
parentcdcf1ebcedb7b9494e2ff7c56e80a3e806ba43d6 (diff)
downloadFreeBSD-src-0d1d9b78d55a52a685b8c7789982a01450ecf8e3.zip
FreeBSD-src-0d1d9b78d55a52a685b8c7789982a01450ecf8e3.tar.gz
MFC r311378:
lm_load: fix string copying issues - Ensure `section` doesn't overrun section by using strlcpy instead of strcpy [*]. - Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity, but is an opportunistic change). CID: 1006826 [*]
Diffstat (limited to 'contrib/bsnmp/snmpd/main.c')
-rw-r--r--contrib/bsnmp/snmpd/main.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c
index 2ab8bbd..a336517 100644
--- a/contrib/bsnmp/snmpd/main.c
+++ b/contrib/bsnmp/snmpd/main.c
@@ -2508,13 +2508,12 @@ lm_load(const char *path, const char *section)
}
m->handle = NULL;
m->flags = 0;
- strcpy(m->section, section);
+ strlcpy(m->section, section, sizeof(m->section));
- if ((m->path = malloc(strlen(path) + 1)) == NULL) {
+ if ((m->path = strdup(path)) == NULL) {
syslog(LOG_ERR, "lm_load: %m");
goto err;
}
- strcpy(m->path, path);
/*
* Make index
OpenPOWER on IntegriCloud