From owner-freebsd-hackers@FreeBSD.ORG Mon May 2 14:41:58 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1879E106567A for ; Mon, 2 May 2011 14:41:58 +0000 (UTC) (envelope-from artemb@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id C16578FC33 for ; Mon, 2 May 2011 14:41:57 +0000 (UTC) Received: by qyk35 with SMTP id 35so1471414qyk.13 for ; Mon, 02 May 2011 07:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=b4AXGjMdi6va9OECcJ1CrHXKLn70Q1nQo0t+mNRtN9w=; b=FnsFp/bCgaOw8awa9K/kc6vlgTTDb/SQFc8+ohFemQjq8sEhjn1ylWzXeXPhKjXi3S TejC/A3HcKOBt9aTh97K5gkZCt3QKhM0N6v1K6yWsutR+bJv8/hicpt0Vrkur0kDEKA2 9uh6e8yV6ZPNgKGuu39Ko4sXfcmzHfLqKlGgg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=LJiroySSDeo68UG2QWdbwRoVzNaMdeoVhz1MifDSS9DV+t/dEAKamIONexlvsqVRZO CPQowE7l7XaKx9jyyeY53OVvJrBsuU/53gnTalqZrFzBKf8AyVP3zjtq/9w/1rkdUgK/ Ml1UnvWJBzhJLvZ3PDeeq2cVhGODbzugMKl8Y= MIME-Version: 1.0 Received: by 10.229.130.3 with SMTP id q3mr6325861qcs.44.1304347316904; Mon, 02 May 2011 07:41:56 -0700 (PDT) Sender: artemb@gmail.com Received: by 10.229.95.140 with HTTP; Mon, 2 May 2011 07:41:56 -0700 (PDT) In-Reply-To: <4DBEBC7A.60607@bytecamp.net> References: <4DBEAAD5.7040906@bytecamp.net> <4DBEBC7A.60607@bytecamp.net> Date: Mon, 2 May 2011 07:41:56 -0700 X-Google-Sender-Auth: JpEcnP09fARapV_S1lkBTqmBUfk Message-ID: From: Artem Belevich To: Robert Schulze Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-hackers@freebsd.org Subject: Re: [LIBC] Modfied Version of sscanf X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2011 14:41:58 -0000 On Mon, May 2, 2011 at 7:15 AM, Robert Schulze 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 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" >