# HG changeset patch # User cboesch # Date 1296588163 0 # Node ID 5c39b0060c2c1498d574b4374ff413ccf858076c # Parent 8e7537586f0b76faecd9f7ef2f232536a5d6b0d7 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. diff -r 8e7537586f0b -r 5c39b0060c2c sub/subreader.c --- 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); } }