summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-07-24 22:38:46 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2016-07-24 22:38:46 +0100
commit7bff70e7466dd80603922ba0dfdad1725cce41a6 (patch)
treeb959566d3802889eed8cabede1b94aeae19b17dd /frontends
parent7417a21bb1f0e8e00958319f60d8c12a9502a353 (diff)
downloadnetsurf-7bff70e7466dd80603922ba0dfdad1725cce41a6.tar.gz
netsurf-7bff70e7466dd80603922ba0dfdad1725cce41a6.tar.bz2
Fix TODO (writing past end of buffer)
Diffstat (limited to 'frontends')
-rwxr-xr-xfrontends/amiga/misc.c19
1 files changed, 10 insertions, 9 deletions
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';
}
}