diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2016-07-24 13:59:30 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2016-07-24 14:03:16 +0100 |
commit | fa2e3b778465cd496aedde8e187038835a765c4f (patch) | |
tree | 106aaf119a4b3925769adb49479274f3c886a148 /frontends/amiga | |
parent | cf753f20cc2a8506c831a5cedd933e3e78417261 (diff) | |
download | netsurf-fa2e3b778465cd496aedde8e187038835a765c4f.tar.gz netsurf-fa2e3b778465cd496aedde8e187038835a765c4f.tar.bz2 |
URL unescape: return the new length to the caller.
The avoids situations were we threw away the length, only for
the caller to have to strlen the returned string.
Note, there seems to be a case of the amiga front end writing
beyond end of allocation. Added a TODO for now.
Diffstat (limited to 'frontends/amiga')
-rwxr-xr-x | frontends/amiga/misc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/frontends/amiga/misc.c b/frontends/amiga/misc.c index 238865120..f15eb48d9 100755 --- a/frontends/amiga/misc.c +++ b/frontends/amiga/misc.c @@ -189,6 +189,7 @@ int32 amiga_warn_user_multi(const char *body, const char *opt1, const char *opt2 static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out) { lwc_string *urlpath; + size_t path_len; char *path; bool match; lwc_string *scheme; @@ -217,7 +218,7 @@ static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out) return NSERROR_BAD_PARAMETER; } - res = url_unescape(lwc_string_data(urlpath) + 1, 0, &path); + res = url_unescape(lwc_string_data(urlpath) + 1, 0, &path_len, &path); lwc_string_unref(urlpath); if (res != NSERROR_OK) { return res; @@ -233,9 +234,10 @@ static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out) } else { - int len = strlen(path); - path[len] = ':'; - path[len + 1] = '\0'; + path[path_len] = ':'; + /* TODO: Looks like we are writing past the end of + * path's allocation here. */ + path[path_len + 1] = '\0'; } } |