On Tue, Oct 21, 2014 at 01:49:41AM +0200, ?ngel Gonz?lez wrote:
> On 21/10/14 01:20, Gabriel Somlo wrote:
> >I think I found a regression in the development branch of wget, which
> >wasn't present in 1.15. Using "git bisect", it appears the offending
> >commit was 8e6de1fb5ff0ca0c749da7db634a1b1e3a1215a2 ("Drop usage of
> >strncpy") from Jun. 9 2014.
> >
> >To reproduce, grab a "wide and shallow" copy of wikipedia.org, like so:
> >
> >
> > wget -rpkEHN -e robots=off --random-wait -t 2 -U mozilla -l 1 \
> > -P ./vservers wikipedia.org
> >
> >
> >then (some 20 minutes or so later) open ./vservers/wikipedia.org/index.html
> >in your (firefox-32.0.2-1.fc20.x86_64) browser as a file.
> >
> Thanks for your report!
>
> After a quick look, get_uri_string seems to not be taking into account the
> end of the url() parameter (it was before 8e6de1fb5).
> Can you check if this patch fixes the issue?
Yeah, that took care of it for me !
Thanks again,
--Gabriel
> diff --git a/src/css-url.c b/src/css-url.c
> index c605798..34a20af 100644
> --- a/src/css-url.c
> +++ b/src/css-url.c
> @@ -72,6 +72,8 @@ extern int yylex (void);
> static char *
> get_uri_string (const char *at, int *pos, int *length)
> {
> + char *uri;
> +
> if (0 != strncasecmp (at + *pos, "url(", 4))
> return NULL;
>
> @@ -97,7 +99,14 @@ get_uri_string (const char *at, int *pos, int *length)
> *length -= 2;
> }
>
> - return xstrdup (at + *pos);
> + uri = xmalloc (*length + 1);
> + if (uri)
> + {
> + strncpy (uri, at + *pos, *length);
> + uri[*length] = '\0';
> + }
> +
> + return uri;
> }
>
> void
>
>