summaryrefslogtreecommitdiff
path: root/apps/plugins/text_editor.c
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-04-09 15:25:17 +0000
committerNils Wallménius <nils@rockbox.org>2008-04-09 15:25:17 +0000
commit6848961aa5f93a290917071ff3496e1d5026621b (patch)
tree70d377348ab0694c356fffd9fe25f095ccbe88fe /apps/plugins/text_editor.c
parentae64d2602befd5589c8c0141a6d812841fdfb232 (diff)
downloadrockbox-6848961aa5f93a290917071ff3496e1d5026621b.zip
rockbox-6848961aa5f93a290917071ff3496e1d5026621b.tar.gz
rockbox-6848961aa5f93a290917071ff3496e1d5026621b.tar.bz2
rockbox-6848961aa5f93a290917071ff3496e1d5026621b.tar.xz
Pass the buffer length to the list_get_name callback functions instead of using hardcoded MAX_PATH
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17049 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_editor.c')
-rw-r--r--apps/plugins/text_editor.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index 75bbccf..5397260 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -115,18 +115,19 @@ int _do_action(int action, char* str, int line)
last_char_index = c;
return 1;
}
-char *list_get_name_cb(int selected_item,void* data,char* buf)
+char *list_get_name_cb(int selected_item, void* data,
+ char* buf, size_t buf_len)
{
char *b = &buffer[do_action(ACTION_GET,0,selected_item)];
(void)data;
- if (rb->strlen(b) >= MAX_PATH)
+ if (rb->strlen(b) >= buf_len)
{
- char t = b[MAX_PATH-10];
- b[MAX_PATH-10] = '\0';
- rb->snprintf(buf,MAX_PATH,"%s ...",b);
- b[MAX_PATH-10] = t;
+ char t = b[buf_len-10];
+ b[buf_len-10] = '\0';
+ rb->snprintf(buf , buf_len, "%s ...", b);
+ b[buf_len-10] = t;
}
- else rb->strcpy(buf,b);
+ else rb->strncpy(buf, b, buf_len);
return buf;
}
char filename[MAX_PATH];