summaryrefslogtreecommitdiff
path: root/apps/bookmark.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-11-23 21:46:13 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2022-11-23 22:09:46 -0500
commit3745c813f924b12232c4f37610aecd23fe5654b8 (patch)
tree41069cc3f39c61b7d0611877d4251827be6cd2e1 /apps/bookmark.c
parent80b8b13544c79f57bf7da6320cee5d76c162e96c (diff)
downloadrockbox-3745c813f924b12232c4f37610aecd23fe5654b8.tar.gz
rockbox-3745c813f924b12232c4f37610aecd23fe5654b8.zip
misc.c open_pathfmt caller supplied buffer
Amachronic raised concern about open() blocking causing a static buf to get overwritten in multiple calls its prudent to just have the caller supply the buffer to minimize stack issues later Change-Id: Iae27c7d063adb1a65688f920f6aa5c395fa5694a
Diffstat (limited to 'apps/bookmark.c')
-rw-r--r--apps/bookmark.c12
1 files changed, 4 insertions, 8 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 */