summaryrefslogtreecommitdiffstats
path: root/apps/cuesheet.c
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-02-05 20:00:14 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-02-05 20:00:14 +0000
commit9e8045cc802760f9ceb2a289323cb28e06c65c52 (patch)
tree388cbd9212c34590ad4f74dc033079766a225a69 /apps/cuesheet.c
parentf67dcf0164e2a382fda3975a223a04e6eda8f9d7 (diff)
downloadrockbox-9e8045cc802760f9ceb2a289323cb28e06c65c52.tar.gz
rockbox-9e8045cc802760f9ceb2a289323cb28e06c65c52.tar.bz2
rockbox-9e8045cc802760f9ceb2a289323cb28e06c65c52.zip
Fix a possible crash in the cuesheet code if the filename lacks a slash, which happens for some reason I don't quite understand yet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16229 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/cuesheet.c')
-rw-r--r--apps/cuesheet.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index e779c8f07d..cac644805f 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -76,16 +76,26 @@ bool cuesheet_is_enabled(void)
bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path)
{
DEBUGF("look for cue file\n");
+
char cuepath[MAX_PATH];
+ char *dot, *slash;
+
+ slash = strrchr(trackpath, '/');
+ if (!slash)
+ {
+ found_cue_path = NULL;
+ return false;
+ }
+
strncpy(cuepath, trackpath, MAX_PATH);
- char *dot = strrchr(cuepath, '.');
+ dot = strrchr(cuepath, '.');
strcpy(dot, ".cue");
int fd = open(cuepath,O_RDONLY);
if (fd < 0)
{
strcpy(cuepath, CUE_DIR);
- strcat(cuepath, strrchr(trackpath, '/'));
+ strcat(cuepath, slash);
char *dot = strrchr(cuepath, '.');
strcpy(dot, ".cue");
fd = open(cuepath,O_RDONLY);