From 9e8045cc802760f9ceb2a289323cb28e06c65c52 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Tue, 5 Feb 2008 20:00:14 +0000 Subject: [PATCH] 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 --- apps/cuesheet.c | 14 ++++++++++++-- 1 file 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);