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). MFC after: 1 week Reported by: Coverity CID: 1006826 [*]
This commit is contained in:
parent
20a4ce8bf2
commit
10a0306a2e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311378
@ -2324,13 +2324,12 @@ lm_load(const char *path, const char *section)
|
|||||||
}
|
}
|
||||||
m->handle = NULL;
|
m->handle = NULL;
|
||||||
m->flags = 0;
|
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");
|
syslog(LOG_ERR, "lm_load: %m");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
strcpy(m->path, path);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make index
|
* Make index
|
||||||
|
Loading…
Reference in New Issue
Block a user