mirror of https://github.com/mpv-player/mpv
cookies: replace sprintf with snprintf
Use snprintf instead of sprintf. No good reason beyond paranoia and Coverity complaining about it. In a very theoretical, construed case the adds might overflow or the environment might change in-between the getenv calls. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35307 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
7d5a6b9b02
commit
86a5b7a4cc
|
@ -207,11 +207,13 @@ static struct cookie_list_type *load_cookies(void)
|
||||||
if (dir) {
|
if (dir) {
|
||||||
while ((ent = readdir(dir)) != NULL) {
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
if ((ent->d_name)[0] != '.') {
|
if ((ent->d_name)[0] != '.') {
|
||||||
buf = malloc(strlen(getenv("HOME")) +
|
const char *home = getenv("HOME");
|
||||||
sizeof("/.mozilla/default/") +
|
unsigned len = strlen(home) +
|
||||||
strlen(ent->d_name) + sizeof("cookies.txt") + 1);
|
sizeof("/.mozilla/default/") +
|
||||||
sprintf(buf, "%s/.mozilla/default/%s/cookies.txt",
|
strlen(ent->d_name) + sizeof("cookies.txt") + 1;
|
||||||
getenv("HOME"), ent->d_name);
|
buf = malloc(len);
|
||||||
|
snprintf(buf, len, "%s/.mozilla/default/%s/cookies.txt",
|
||||||
|
home, ent->d_name);
|
||||||
list = load_cookies_from(buf, list);
|
list = load_cookies_from(buf, list);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue