Mercurial > mplayer.hg
changeset 32752:5c39b0060c2c
Use mp_dir_join instead of sprintf.
This avoids a potential heap overflow and create a cleaner path: no double "//"
in the path for example, or even "\\/" on DOS-like systems.
author | cboesch |
---|---|
date | Tue, 01 Feb 2011 19:22:43 +0000 |
parents | 8e7537586f0b |
children | 9981c24b59bd |
files | sub/subreader.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sub/subreader.c Tue Feb 01 19:17:33 2011 +0000 +++ b/sub/subreader.c Tue Feb 01 19:22:43 2011 +0000 @@ -2012,21 +2012,23 @@ } if (prio) { + char *subpath; prio += prio; #ifdef CONFIG_ICONV if (i < 3){ // prefer UTF-8 coded prio++; } #endif - sprintf(tmpresult, "%s/%s", path, de->d_name); - // fprintf(stderr, "%s priority %d\n", tmpresult, prio); - if ((f = fopen(tmpresult, "rt"))) { + subpath = mp_dir_join(path, de->d_name); + // fprintf(stderr, "%s priority %d\n", subpath, prio); + if ((f = fopen(subpath, "rt"))) { struct subfn *sub = &slist->subs[slist->sid++]; fclose(f); sub->priority = prio; - sub->fname = strdup(tmpresult); - } + sub->fname = subpath; + } else + free(subpath); } }