lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1263826439.28171.4006.camel@gandalf.stny.rr.com>
Date:	Mon, 18 Jan 2010 09:53:59 -0500
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Alex Riesen <raa.lkml@...il.com>
Cc:	Li Zefan <lizf@...fujitsu.com>, Ingo Molnar <mingo@...e.hu>,
	Frederic Weisbecker <fweisbec@...il.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/7] lib: Introduce strnstr()

On Sat, 2010-01-16 at 12:12 +0100, Alex Riesen wrote:
> On Thu, Jan 14, 2010 at 03:53, Li Zefan <lizf@...fujitsu.com> wrote:
> > @@ -667,7 +667,7 @@ EXPORT_SYMBOL(memscan);
> >  */
> >  char *strstr(const char *s1, const char *s2)
> >  {
> > -       int l1, l2;
> > +       size_t l1, l2;
> >
> 
> This chunk is not related, is it?

Actually it is related. Making both strstr and strnstr use the correct
variable and be consistent. This patch introduces strnstr and in doing
so also makes strstr consistent (and correct) with strnstr.

> 
> > @@ -684,6 +684,31 @@ char *strstr(const char *s1, const char *s2)
> >  EXPORT_SYMBOL(strstr);
> >  #endif
> >
> > +#ifndef __HAVE_ARCH_STRNSTR
> > +/**
> > + * strnstr - Find the first substring in a length-limited string
> > + * @s1: The string to be searched
> > + * @s2: The string to search for
> > + * @len: the maximum number of characters to search
> > + */
> > +char *strnstr(const char *s1, const char *s2, size_t len)
> > +{
> > +       size_t l1 = len, l2;
> 
> Are you sure you want to search _past_ the NUL-terminator
> of s1?
> 
> > +       l2 = strlen(s2);
> > +       if (!l2)
> > +               return (char *)s1;
> > +       while (l1 >= l2) {
> > +               l1--;

The first check is len-1, I don't see it searching past the
NUL-terminator. The loop will stop when l1 == l2 (the size of s2) and s1
pointing near the end of the string.

-- Steve

> > +               if (!memcmp(s1, s2, l2))
> > +                       return (char *)s1;
> > +               s1++;
> > +       }
> > +       return NULL;
> > +}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ