]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorAndreas Jaeger <aj@suse.de>
Thu, 18 May 2000 05:35:38 +0000 (05:35 +0000)
committerAndreas Jaeger <aj@suse.de>
Thu, 18 May 2000 05:35:38 +0000 (05:35 +0000)
* sysdeps/generic/memmem.c (memmem): Check arguments to avoid
possibly searching through the whole memory.
Closes PR libc/1730, reported by Greg Hudson <ghudson@mit.edu>.

ChangeLog
sysdeps/generic/memmem.c

index 086f8e4bdb1006f862035c3a52dbbf037484469c..91e2c193fbf8fae27a177811fe9c8b7104442001 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * string/strings.h: Add pure and const attributes if possible.
 
+       * sysdeps/generic/memmem.c (memmem): Check arguments to avoid
+       possibly searching through the whole memory.
+       Closes PR libc/1730, reported by Greg Hudson <ghudson@mit.edu>.
+
 2000-05-17  Jakub Jelinek  <jakub@redhat.com>
 
        * sysdeps/generic/dl-cache.h (_DL_CACHE_DEFAULT_ID): Only define if
index 9e32f517b3142680e972ede12721eb4019155ec2..e9b270870a4759bd914c12e9127d9500a59ee0b5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,96,97,98,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -38,6 +38,11 @@ memmem (haystack, haystack_len, needle, needle_len)
        the beginning of the string.  */
     return (void *) haystack;
 
+  /* Sanity check, otherwise the loop might search through the whole
+     memory.  */
+  if (__builtin_expect (haystack_len < needle_len, 0))
+    return NULL;
+
   for (begin = (const char *) haystack; begin <= last_possible; ++begin)
     if (begin[0] == ((const char *) needle)[0] &&
        !memcmp ((const void *) &begin[1],