Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 May 2011 07:41:56 -0700
From:      Artem Belevich <art@freebsd.org>
To:        Robert Schulze <rs@bytecamp.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: [LIBC] Modfied Version of sscanf
Message-ID:  <BANLkTikTykeWDN3xR9dYJxWbhKGhmRPNTg@mail.gmail.com>
In-Reply-To: <4DBEBC7A.60607@bytecamp.net>
References:  <C9E46C77.389%moeller.akt@googlemail.com> <4DBEAAD5.7040906@bytecamp.net> <BANLkTim_WhRdWi8RbuubxQm4kD27V17h9g@mail.gmail.com> <4DBEBC7A.60607@bytecamp.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, May 2, 2011 at 7:15 AM, Robert Schulze <rs@bytecamp.net> wrote:
> Hi,
>
> Am 02.05.2011 16:06, schrieb Artem Belevich:
>>
>> Second problem -- res on success will always be "" as you've just did
>> *ptr=0.
>
> thats right, the copy should look like:
>
> res=strdup(str+4);
>
>> Bzzt!
>>
>> Try it on "GET blah_HTTP/1.1.1.1.1.1_whatever HTTP/1.1"
>
> will return "blah_HTTP/1.1.1.1.1.1_whatever" as resource.
> It should be the next step to check whether <resource> is valid.

Oops. Should've been space after blah, not underscore.

>        if(ptr && (ptr=strstr(ptr," HTTP/1.1"))) /* find end of res */

Contrary to the comment in the code you're not checking for "HTTP/1.1"
at the end but you're checking for it *anywhere* in the string. While
it will occur at the end of valid input string, nobody said it can't
occur in the middle, too. Original requirement was saying "surrounded
by GET and HTTP/1.1".

--Artem

>
> with kind regards,
> Robert Schulze
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTikTykeWDN3xR9dYJxWbhKGhmRPNTg>