[LIBC] Modfied Version of sscanf

Artem Belevich art at freebsd.org
Mon May 2 14:41:58 UTC 2011


On Mon, May 2, 2011 at 7:15 AM, Robert Schulze <rs at 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 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>


More information about the freebsd-hackers mailing list