diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmark.c | 12 | ||||
-rw-r--r-- | apps/debug_menu.c | 3 | ||||
-rw-r--r-- | apps/filetypes.c | 9 | ||||
-rw-r--r-- | apps/gui/icon.c | 4 | ||||
-rw-r--r-- | apps/logfdisp.c | 3 | ||||
-rw-r--r-- | apps/misc.c | 5 | ||||
-rw-r--r-- | apps/misc.h | 2 | ||||
-rw-r--r-- | apps/tagcache.c | 19 | ||||
-rw-r--r-- | apps/talk.c | 4 |
9 files changed, 34 insertions, 27 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index 20841b4940..8256f76ef8 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -290,10 +290,8 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark, | |||
290 | bool equal; | 290 | bool equal; |
291 | 291 | ||
292 | /* Opening up a temp bookmark file */ | 292 | /* Opening up a temp bookmark file */ |
293 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), | 293 | temp_bookmark_file = open_pathfmt(global_temp_buffer, sizeof(global_temp_buffer), |
294 | "%s.tmp", bookmark_file_name); | 294 | O_WRONLY | O_CREAT | O_TRUNC, "%s.tmp", bookmark_file_name); |
295 | temp_bookmark_file = open(global_temp_buffer, | ||
296 | O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
297 | if (temp_bookmark_file < 0) | 295 | if (temp_bookmark_file < 0) |
298 | return false; /* can't open the temp file */ | 296 | return false; /* can't open the temp file */ |
299 | 297 | ||
@@ -893,10 +891,8 @@ static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id) | |||
893 | int bookmark_count = 0; | 891 | int bookmark_count = 0; |
894 | 892 | ||
895 | /* Opening up a temp bookmark file */ | 893 | /* Opening up a temp bookmark file */ |
896 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), | 894 | temp_bookmark_file = open_pathfmt(global_temp_buffer, sizeof(global_temp_buffer), |
897 | "%s.tmp", bookmark_file_name); | 895 | O_WRONLY | O_CREAT | O_TRUNC, "%s.tmp", bookmark_file_name); |
898 | temp_bookmark_file = open(global_temp_buffer, | ||
899 | O_WRONLY | O_CREAT | O_TRUNC, 0666); | ||
900 | 896 | ||
901 | if (temp_bookmark_file < 0) | 897 | if (temp_bookmark_file < 0) |
902 | return false; /* can't open the temp file */ | 898 | return false; /* can't open the temp file */ |
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a4bfe65b1c..71c0395e6e 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -2307,8 +2307,9 @@ static bool cpu_boost_log_dump(void) | |||
2307 | return false; | 2307 | return false; |
2308 | 2308 | ||
2309 | #if CONFIG_RTC | 2309 | #if CONFIG_RTC |
2310 | char fname[MAX_PATH]; | ||
2310 | struct tm *nowtm = get_time(); | 2311 | struct tm *nowtm = get_time(); |
2311 | fd = open_pathfmt(O_CREAT|O_WRONLY|O_TRUNC, | 2312 | fd = open_pathfmt(fname, sizeof(fname), O_CREAT|O_WRONLY|O_TRUNC, |
2312 | "%s/boostlog_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, | 2313 | "%s/boostlog_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, |
2313 | nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, | 2314 | nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, |
2314 | nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); | 2315 | nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); |
diff --git a/apps/filetypes.c b/apps/filetypes.c index d690b554fd..ec9bd1a7ae 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -325,8 +325,8 @@ void read_color_theme_file(void) { | |||
325 | if (!global_settings.colors_file[0] || global_settings.colors_file[0] == '-') | 325 | if (!global_settings.colors_file[0] || global_settings.colors_file[0] == '-') |
326 | return; | 326 | return; |
327 | 327 | ||
328 | fd = open_pathfmt(O_RDONLY, THEME_DIR "/%s.colours", | 328 | fd = open_pathfmt(buffer, sizeof(buffer), O_RDONLY, |
329 | global_settings.colors_file); | 329 | THEME_DIR "/%s.colours", global_settings.colors_file); |
330 | if (fd < 0) | 330 | if (fd < 0) |
331 | return; | 331 | return; |
332 | while (read_line(fd, buffer, MAX_PATH) > 0) | 332 | while (read_line(fd, buffer, MAX_PATH) > 0) |
@@ -365,10 +365,11 @@ void read_viewer_theme_file(void) | |||
365 | custom_filetype_icons[i] = filetypes[i].icon; | 365 | custom_filetype_icons[i] = filetypes[i].icon; |
366 | } | 366 | } |
367 | 367 | ||
368 | fd = open_pathfmt(O_RDONLY, "%s/%s.icons", ICON_DIR, | 368 | fd = open_pathfmt(buffer, sizeof(buffer), O_RDONLY, |
369 | global_settings.viewers_icon_file); | 369 | ICON_DIR "/%s.icons", global_settings.viewers_icon_file); |
370 | if (fd < 0) | 370 | if (fd < 0) |
371 | return; | 371 | return; |
372 | |||
372 | while (read_line(fd, buffer, MAX_PATH) > 0) | 373 | while (read_line(fd, buffer, MAX_PATH) > 0) |
373 | { | 374 | { |
374 | if (!settings_parseline(buffer, &ext, &icon)) | 375 | if (!settings_parseline(buffer, &ext, &icon)) |
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index 2c09f88852..9deb1a0c65 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -182,7 +182,9 @@ static void load_icons(const char* filename, enum Iconset iconset, | |||
182 | ic->handle = 0; | 182 | ic->handle = 0; |
183 | if (filename[0] && filename[0] != '-') | 183 | if (filename[0] && filename[0] != '-') |
184 | { | 184 | { |
185 | fd = open_pathfmt(O_RDONLY, ICON_DIR "/%s.bmp", filename); | 185 | char fname[MAX_PATH]; |
186 | fd = open_pathfmt(fname, sizeof(fname), O_RDONLY, | ||
187 | ICON_DIR "/%s.bmp", filename); | ||
186 | if (fd < 0) | 188 | if (fd < 0) |
187 | return; | 189 | return; |
188 | buf_size = read_bmp_fd(fd, &ic->bmp, 0, | 190 | buf_size = read_bmp_fd(fd, &ic->bmp, 0, |
diff --git a/apps/logfdisp.c b/apps/logfdisp.c index aebc9ffb33..efbfa192f5 100644 --- a/apps/logfdisp.c +++ b/apps/logfdisp.c | |||
@@ -225,8 +225,9 @@ bool logfdump(void) | |||
225 | logfenabled = false; | 225 | logfenabled = false; |
226 | 226 | ||
227 | #if CONFIG_RTC | 227 | #if CONFIG_RTC |
228 | char fname[MAX_PATH]; | ||
228 | struct tm *nowtm = get_time(); | 229 | struct tm *nowtm = get_time(); |
229 | fd = open_pathfmt(O_CREAT|O_WRONLY|O_TRUNC, | 230 | fd = open_pathfmt(fname, sizeof(fname), O_CREAT|O_WRONLY|O_TRUNC, |
230 | "%s/logf_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, | 231 | "%s/logf_%04d%02d%02d%02d%02d%02d.txt", ROCKBOX_DIR, |
231 | nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, | 232 | nowtm->tm_year + 1900, nowtm->tm_mon + 1, nowtm->tm_mday, |
232 | nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); | 233 | nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec); |
diff --git a/apps/misc.c b/apps/misc.c index e2913d53b3..eb821548fe 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1419,12 +1419,11 @@ int string_option(const char *option, const char *const oplist[], bool ignore_ca | |||
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | /* open but with a builtin printf for assembling the path */ | 1421 | /* open but with a builtin printf for assembling the path */ |
1422 | int open_pathfmt(int oflag, const char *pathfmt, ...) | 1422 | int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...) |
1423 | { | 1423 | { |
1424 | static char buf[MAX_PATH]; | ||
1425 | va_list ap; | 1424 | va_list ap; |
1426 | va_start(ap, pathfmt); | 1425 | va_start(ap, pathfmt); |
1427 | vsnprintf(buf, sizeof(buf), pathfmt, ap); | 1426 | vsnprintf(buf, size, pathfmt, ap); |
1428 | va_end(ap); | 1427 | va_end(ap); |
1429 | return open(buf, oflag, 0666); | 1428 | return open(buf, oflag, 0666); |
1430 | } | 1429 | } |
diff --git a/apps/misc.h b/apps/misc.h index 50191f0e95..f31d4d363c 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -122,7 +122,7 @@ extern int show_logo(void); | |||
122 | #define BOM_UTF_16_SIZE 2 | 122 | #define BOM_UTF_16_SIZE 2 |
123 | 123 | ||
124 | int split_string(char *str, const char needle, char *vector[], int vector_length); | 124 | int split_string(char *str, const char needle, char *vector[], int vector_length); |
125 | int open_pathfmt(int oflag, const char *pathfmt, ...); | 125 | int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...); |
126 | int open_utf8(const char* pathname, int flags); | 126 | int open_utf8(const char* pathname, int flags); |
127 | int string_option(const char *option, const char *const oplist[], bool ignore_case); | 127 | int string_option(const char *option, const char *const oplist[], bool ignore_case); |
128 | 128 | ||
diff --git a/apps/tagcache.c b/apps/tagcache.c index a297bc7353..a66f9658ae 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -423,11 +423,13 @@ static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write) | |||
423 | { | 423 | { |
424 | int fd; | 424 | int fd; |
425 | int rc; | 425 | int rc; |
426 | char fname[MAX_PATH]; | ||
426 | 427 | ||
427 | if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT) | 428 | if (TAGCACHE_IS_NUMERIC(tag) || tag < 0 || tag >= TAG_COUNT) |
428 | return -1; | 429 | return -1; |
429 | 430 | ||
430 | fd = open_pathfmt(write ? O_RDWR : O_RDONLY, TAGCACHE_FILE_INDEX, tag); | 431 | fd = open_pathfmt(fname, sizeof(fname), |
432 | write ? O_RDWR : O_RDONLY, TAGCACHE_FILE_INDEX, tag); | ||
431 | 433 | ||
432 | if (fd < 0) | 434 | if (fd < 0) |
433 | { | 435 | { |
@@ -803,7 +805,9 @@ static bool open_files(struct tagcache_search *tcs, int tag) | |||
803 | { | 805 | { |
804 | if (tcs->idxfd[tag] < 0) | 806 | if (tcs->idxfd[tag] < 0) |
805 | { | 807 | { |
806 | tcs->idxfd[tag] = open_pathfmt(O_RDONLY, TAGCACHE_FILE_INDEX, tag); | 808 | char fname[MAX_PATH]; |
809 | tcs->idxfd[tag] = open_pathfmt(fname, sizeof(fname), | ||
810 | O_RDONLY, TAGCACHE_FILE_INDEX, tag); | ||
807 | } | 811 | } |
808 | 812 | ||
809 | if (tcs->idxfd[tag] < 0) | 813 | if (tcs->idxfd[tag] < 0) |
@@ -1583,9 +1587,10 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs, | |||
1583 | } | 1587 | } |
1584 | 1588 | ||
1585 | if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0) | 1589 | if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0) |
1586 | { | 1590 | { |
1587 | tcs->idxfd[clause->tag] = open_pathfmt(O_RDONLY, | 1591 | char fname[MAX_PATH]; |
1588 | TAGCACHE_FILE_INDEX, clause->tag); | 1592 | tcs->idxfd[clause->tag] = open_pathfmt(fname, sizeof(fname), O_RDONLY, |
1593 | TAGCACHE_FILE_INDEX, clause->tag); | ||
1589 | } | 1594 | } |
1590 | } | 1595 | } |
1591 | 1596 | ||
@@ -2743,7 +2748,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd) | |||
2743 | * Creating new index file to store the tags. No need to preload | 2748 | * Creating new index file to store the tags. No need to preload |
2744 | * anything whether the index type is sorted or not. | 2749 | * anything whether the index type is sorted or not. |
2745 | */ | 2750 | */ |
2746 | fd = open_pathfmt(O_WRONLY | O_CREAT | O_TRUNC, | 2751 | fd = open_pathfmt(buf, bufsz, O_WRONLY | O_CREAT | O_TRUNC, |
2747 | TAGCACHE_FILE_INDEX, index_type); | 2752 | TAGCACHE_FILE_INDEX, index_type); |
2748 | if (fd < 0) | 2753 | if (fd < 0) |
2749 | { | 2754 | { |
@@ -4401,7 +4406,7 @@ static bool check_deleted_files(void) | |||
4401 | 4406 | ||
4402 | logf("reverse scan..."); | 4407 | logf("reverse scan..."); |
4403 | 4408 | ||
4404 | fd = open_pathfmt(O_RDONLY, TAGCACHE_FILE_INDEX, tag_filename); | 4409 | fd = open_pathfmt(buf, bufsz, O_RDONLY, TAGCACHE_FILE_INDEX, tag_filename); |
4405 | if (fd < 0) | 4410 | if (fd < 0) |
4406 | { | 4411 | { |
4407 | logf(TAGCACHE_FILE_INDEX " open fail", tag_filename); | 4412 | logf(TAGCACHE_FILE_INDEX " open fail", tag_filename); |
diff --git a/apps/talk.c b/apps/talk.c index 89319ae9a2..c3a1148df4 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -247,6 +247,7 @@ static struct buflib_callbacks talk_ops = { | |||
247 | 247 | ||
248 | static int open_voicefile(void) | 248 | static int open_voicefile(void) |
249 | { | 249 | { |
250 | char fname[MAX_PATH]; | ||
250 | char* p_lang = DEFAULT_VOICE_LANG; /* default */ | 251 | char* p_lang = DEFAULT_VOICE_LANG; /* default */ |
251 | 252 | ||
252 | if ( global_settings.lang_file[0] && | 253 | if ( global_settings.lang_file[0] && |
@@ -255,7 +256,8 @@ static int open_voicefile(void) | |||
255 | p_lang = (char *)global_settings.lang_file; | 256 | p_lang = (char *)global_settings.lang_file; |
256 | } | 257 | } |
257 | 258 | ||
258 | return open_pathfmt(O_RDONLY, LANG_DIR "/%s.voice", p_lang); | 259 | return open_pathfmt(fname, sizeof(fname), |
260 | O_RDONLY, LANG_DIR "/%s.voice", p_lang); | ||
259 | } | 261 | } |
260 | 262 | ||
261 | 263 | ||