diff options
author | ngie <ngie@FreeBSD.org> | 2017-01-13 09:04:26 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-01-13 09:04:26 +0000 |
commit | 0d1d9b78d55a52a685b8c7789982a01450ecf8e3 (patch) | |
tree | 975118d083ad109f72d8f6dcd9ee60959b387be1 /contrib/bsnmp/snmpd/main.c | |
parent | cdcf1ebcedb7b9494e2ff7c56e80a3e806ba43d6 (diff) | |
download | FreeBSD-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.c | 5 |
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 |