diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2012-10-31 19:01:55 +0000 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-31 22:45:04 +0100 |
commit | 86a5b7a4cc09b69eb108f8ef9fcb01811d7fa879 (patch) | |
tree | 6dcf6e5c9ff2908406b9c7381b5fc6ae8adfedf2 /stream/cookies.c | |
parent | 7d5a6b9b02f41130eb26ff4f2d71aee1d0488ea3 (diff) | |
download | mpv-86a5b7a4cc09b69eb108f8ef9fcb01811d7fa879.tar.bz2 mpv-86a5b7a4cc09b69eb108f8ef9fcb01811d7fa879.tar.xz |
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
Diffstat (limited to 'stream/cookies.c')
-rw-r--r-- | stream/cookies.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/stream/cookies.c b/stream/cookies.c index e50274a248..6a1ad4466d 100644 --- a/stream/cookies.c +++ b/stream/cookies.c @@ -207,11 +207,13 @@ static struct cookie_list_type *load_cookies(void) if (dir) { while ((ent = readdir(dir)) != NULL) { if ((ent->d_name)[0] != '.') { - buf = malloc(strlen(getenv("HOME")) + - sizeof("/.mozilla/default/") + - strlen(ent->d_name) + sizeof("cookies.txt") + 1); - sprintf(buf, "%s/.mozilla/default/%s/cookies.txt", - getenv("HOME"), ent->d_name); + const char *home = getenv("HOME"); + unsigned len = strlen(home) + + sizeof("/.mozilla/default/") + + strlen(ent->d_name) + sizeof("cookies.txt") + 1; + buf = malloc(len); + snprintf(buf, len, "%s/.mozilla/default/%s/cookies.txt", + home, ent->d_name); list = load_cookies_from(buf, list); free(buf); } |