summaryrefslogtreecommitdiffstats
path: root/apps/plugins/properties.c
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2009-07-14 13:57:45 +0000
committerNils Wallménius <nils@rockbox.org>2009-07-14 13:57:45 +0000
commit3d4701a6e41616cf581a297bab1451cf2db70249 (patch)
treef845837c96ffbed7d59ddf8308f3b3e7c40cb8c9 /apps/plugins/properties.c
parentc2900a1bacd5d98b57a0d15ea2add1bc08764057 (diff)
downloadrockbox-3d4701a6e41616cf581a297bab1451cf2db70249.tar.gz
rockbox-3d4701a6e41616cf581a297bab1451cf2db70249.tar.bz2
rockbox-3d4701a6e41616cf581a297bab1451cf2db70249.zip
FS#10080
* Move strncpy() from core to the pluginlib * Introduce strlcpy() and use that instead in most places (use memcpy in a few) in core and some plugins * Drop strncpy() from the codec api as no codec used it * Bump codec and plugin api versions git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21863 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/properties.c')
-rw-r--r--apps/plugins/properties.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index 18beec2da6..b57150b817 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -70,8 +70,7 @@ static bool file_properties(char* selected_file)
char* ptr = rb->strrchr(selected_file, '/') + 1;
int dirlen = (ptr - selected_file);
- rb->strncpy(tstr, selected_file, dirlen);
- tstr[dirlen] = 0;
+ rb->strlcpy(tstr, selected_file, dirlen + 1);
dir = rb->opendir(tstr);
if (dir)
@@ -212,7 +211,7 @@ static bool dir_properties(char* selected_file)
{
DPS dps;
char tstr[64];
- rb->strncpy(dps.dirname, selected_file, MAX_PATH);
+ rb->strlcpy(dps.dirname, selected_file, MAX_PATH);
dps.len = MAX_PATH;
dps.dc = 0;
dps.fc = 0;
@@ -220,7 +219,7 @@ static bool dir_properties(char* selected_file)
if(false == _dir_properties(&dps))
return false;
- rb->strncpy(str_dirname, selected_file, MAX_PATH);
+ rb->strlcpy(str_dirname, selected_file, MAX_PATH);
rb->snprintf(str_dircount, sizeof str_dircount, "Subdirs: %d", dps.dc);
rb->snprintf(str_filecount, sizeof str_filecount, "Files: %d", dps.fc);
rb->snprintf(str_size, sizeof str_size, "Size: %s",
@@ -236,35 +235,35 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
switch(selected_item)
{
case 0:
- rb->strncpy(buffer, str_dirname, buffer_len);
+ rb->strlcpy(buffer, str_dirname, buffer_len);
break;
case 1:
- rb->strncpy(buffer, its_a_dir ? str_dircount : str_filename,
+ rb->strlcpy(buffer, its_a_dir ? str_dircount : str_filename,
buffer_len);
break;
case 2:
- rb->strncpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len);
break;
case 3:
- rb->strncpy(buffer, its_a_dir ? str_size : str_date, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? str_size : str_date, buffer_len);
break;
case 4:
- rb->strncpy(buffer, its_a_dir ? "" : str_time, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? "" : str_time, buffer_len);
break;
case 5:
- rb->strncpy(buffer, its_a_dir ? "" : str_artist, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? "" : str_artist, buffer_len);
break;
case 6:
- rb->strncpy(buffer, its_a_dir ? "" : str_title, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? "" : str_title, buffer_len);
break;
case 7:
- rb->strncpy(buffer, its_a_dir ? "" : str_album, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? "" : str_album, buffer_len);
break;
case 8:
- rb->strncpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
+ rb->strlcpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
break;
default:
- rb->strncpy(buffer, "ERROR", buffer_len);
+ rb->strlcpy(buffer, "ERROR", buffer_len);
break;
}
return buffer;
@@ -284,8 +283,7 @@ enum plugin_status plugin_start(const void* parameter)
struct dirent* entry;
char* ptr = rb->strrchr(file, '/') + 1;
int dirlen = (ptr - file);
- rb->strncpy(str_dirname, file, dirlen);
- str_dirname[dirlen] = 0;
+ rb->strlcpy(str_dirname, file, dirlen + 1);
dir = rb->opendir(str_dirname);
if (dir)