From 7bff70e7466dd80603922ba0dfdad1725cce41a6 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 24 Jul 2016 22:38:46 +0100 Subject: Fix TODO (writing past end of buffer) --- frontends/amiga/misc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'frontends') diff --git a/frontends/amiga/misc.c b/frontends/amiga/misc.c index f15eb48d9..c09b28308 100755 --- a/frontends/amiga/misc.c +++ b/frontends/amiga/misc.c @@ -225,18 +225,19 @@ static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out) } colon = strchr(path, ':'); - if(colon == NULL) - { + if(colon == NULL) { slash = strchr(path, '/'); - if(slash) - { + if(slash) { *slash = ':'; - } - else - { + } else { + char *tmp_path = malloc(path_len + 2); + if(tmp_path == NULL) return NSERROR_NOMEM; + + strncpy(tmp_path, path, path_len); + free(path); + + path = tmp_path; path[path_len] = ':'; - /* TODO: Looks like we are writing past the end of - * path's allocation here. */ path[path_len + 1] = '\0'; } } -- cgit v1.2.3