diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2016-07-24 22:38:46 +0100 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2016-07-24 22:38:46 +0100 |
commit | 7bff70e7466dd80603922ba0dfdad1725cce41a6 (patch) | |
tree | b959566d3802889eed8cabede1b94aeae19b17dd /frontends/amiga | |
parent | 7417a21bb1f0e8e00958319f60d8c12a9502a353 (diff) | |
download | netsurf-7bff70e7466dd80603922ba0dfdad1725cce41a6.tar.gz netsurf-7bff70e7466dd80603922ba0dfdad1725cce41a6.tar.bz2 |
Fix TODO (writing past end of buffer)
Diffstat (limited to 'frontends/amiga')
-rwxr-xr-x | frontends/amiga/misc.c | 19 |
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'; } } |