This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.18-242-g66a9be9


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  66a9be9d58e83856e398fbb484e7f2637d7f100b (commit)
       via  1bc92709f336f8f7d5cc3e47a0fec654f57382fe (commit)
       via  27d0461b7bb00e8863dbb2087ce22bf67f9c1018 (commit)
       via  215c7d43444a64fcb571381ebcd39c7514c7b4ff (commit)
      from  4cb81307b3771672864fa3a7498bd39c13267a00 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=66a9be9d58e83856e398fbb484e7f2637d7f100b

commit 66a9be9d58e83856e398fbb484e7f2637d7f100b
Author: Will Newton <will.newton@linaro.org>
Date:   Thu Oct 3 11:26:34 2013 +0100

    malloc/tst-valloc.c: Tidy up code.
    
    Add some comments and call free on all potentially allocated pointers.
    Also remove duplicate check for NULL pointer.
    
    ChangeLog:
    
    2013-10-04  Will Newton  <will.newton@linaro.org>
    
    	* malloc/tst-valloc.c: Add comments.
    	(do_test): Add comments and call free on all potentially
    	allocated pointers. Remove duplicate check for NULL pointer.
    	Add space after cast.

diff --git a/ChangeLog b/ChangeLog
index 9781761..7a7b6bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,11 @@
 	allocated pointers. Remove duplicate check for NULL pointer.
 	Add space after cast.
 
+	* malloc/tst-valloc.c: Add comments.
+	(do_test): Add comments and call free on all potentially
+	allocated pointers. Remove duplicate check for NULL pointer.
+	Add space after cast.
+
 2013-10-04  Alan Modra  <amodra@gmail.com>
 
 	* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
diff --git a/malloc/tst-valloc.c b/malloc/tst-valloc.c
index 3648f2f..4fd0dbb 100644
--- a/malloc/tst-valloc.c
+++ b/malloc/tst-valloc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2013 Free Software Foundation, Inc.
+/* Test for valloc.
+   Copyright (C) 2013 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
@@ -34,12 +35,14 @@ static int
 do_test (void)
 {
   void *p;
-  unsigned long pagesize = getpagesize();
+  unsigned long pagesize = getpagesize ();
   unsigned long ptrval;
   int save;
 
   errno = 0;
 
+  /* An attempt to allocate a huge value should return NULL and set
+     errno to ENOMEM.  */
   p = valloc (-1);
 
   save = errno;
@@ -50,8 +53,11 @@ do_test (void)
   if (p == NULL && save != ENOMEM)
     merror ("valloc (-1) errno is not set correctly");
 
+  free (p);
+
   errno = 0;
 
+  /* Test to expose integer overflow in malloc internals from BZ #15856.  */
   p = valloc (-pagesize);
 
   save = errno;
@@ -62,6 +68,10 @@ do_test (void)
   if (p == NULL && save != ENOMEM)
     merror ("valloc (-pagesize) errno is not set correctly");
 
+  free (p);
+
+  /* A zero-sized allocation should succeed with glibc, returning a
+     non-NULL value.  */
   p = valloc (0);
 
   if (p == NULL)
@@ -69,15 +79,13 @@ do_test (void)
 
   free (p);
 
+  /* Check the alignment of the returned pointer is correct.  */
   p = valloc (32);
 
   if (p == NULL)
     merror ("valloc (32) failed.");
 
-  ptrval = (unsigned long)p;
-
-  if (p == NULL)
-    merror ("valloc (32) failed.");
+  ptrval = (unsigned long) p;
 
   if ((ptrval & (pagesize - 1)) != 0)
     merror ("returned pointer is not page aligned.");

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1bc92709f336f8f7d5cc3e47a0fec654f57382fe

commit 1bc92709f336f8f7d5cc3e47a0fec654f57382fe
Author: Will Newton <will.newton@linaro.org>
Date:   Thu Oct 3 11:24:38 2013 +0100

    malloc/tst-pvalloc.c: Tidy up code.
    
    Add some comments and call free on all potentially allocated pointers.
    Also remove duplicate check for NULL pointer.
    
    ChangeLog:
    
    2013-10-04  Will Newton  <will.newton@linaro.org>
    
    	* malloc/tst-pvalloc.c: Add comments.
    	(do_test): Add comments and call free on all potentially
    	allocated pointers. Remove duplicate check for NULL pointer.
    	Add space after cast.

diff --git a/ChangeLog b/ChangeLog
index fab61a0..9781761 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,11 @@
 	(do_test): Add comments and call free on all potentially
 	allocated pointers. Add space after cast.
 
+	* malloc/tst-pvalloc.c: Add comments.
+	(do_test): Add comments and call free on all potentially
+	allocated pointers. Remove duplicate check for NULL pointer.
+	Add space after cast.
+
 2013-10-04  Alan Modra  <amodra@gmail.com>
 
 	* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
diff --git a/malloc/tst-pvalloc.c b/malloc/tst-pvalloc.c
index 1126672..1c81294 100644
--- a/malloc/tst-pvalloc.c
+++ b/malloc/tst-pvalloc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2013 Free Software Foundation, Inc.
+/* Test for pvalloc.
+   Copyright (C) 2013 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
@@ -34,12 +35,14 @@ static int
 do_test (void)
 {
   void *p;
-  unsigned long pagesize = getpagesize();
+  unsigned long pagesize = getpagesize ();
   unsigned long ptrval;
   int save;
 
   errno = 0;
 
+  /* An attempt to allocate a huge value should return NULL and set
+     errno to ENOMEM.  */
   p = pvalloc (-1);
 
   save = errno;
@@ -50,8 +53,11 @@ do_test (void)
   if (p == NULL && save != ENOMEM)
     merror ("pvalloc (-1) errno is not set correctly");
 
+  free (p);
+
   errno = 0;
 
+  /* Test to expose integer overflow in malloc internals from BZ #15855.  */
   p = pvalloc (-pagesize);
 
   save = errno;
@@ -62,6 +68,10 @@ do_test (void)
   if (p == NULL && save != ENOMEM)
     merror ("pvalloc (-pagesize) errno is not set correctly");
 
+  free (p);
+
+  /* A zero-sized allocation should succeed with glibc, returning a
+     non-NULL value.  */
   p = pvalloc (0);
 
   if (p == NULL)
@@ -69,15 +79,13 @@ do_test (void)
 
   free (p);
 
+  /* Check the alignment of the returned pointer is correct.  */
   p = pvalloc (32);
 
   if (p == NULL)
     merror ("pvalloc (32) failed.");
 
-  ptrval = (unsigned long)p;
-
-  if (p == NULL)
-    merror ("pvalloc (32) failed.");
+  ptrval = (unsigned long) p;
 
   if ((ptrval & (pagesize - 1)) != 0)
     merror ("returned pointer is not page aligned.");

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=27d0461b7bb00e8863dbb2087ce22bf67f9c1018

commit 27d0461b7bb00e8863dbb2087ce22bf67f9c1018
Author: Will Newton <will.newton@linaro.org>
Date:   Thu Oct 3 11:21:15 2013 +0100

    malloc/tst-posix_memalign.c: Tidy up code.
    
    Add some comments and call free on all potentially allocated pointers.
    
    ChangeLog:
    
    2013-10-04  Will Newton  <will.newton@linaro.org>
    
    	* malloc/tst-posix_memalign.c: Add comments.
    	(do_test): Add comments and call free on all potentially
    	allocated pointers. Add space after cast.

diff --git a/ChangeLog b/ChangeLog
index 7c26881..fab61a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
 	* malloc/Makefile: Add tst-memalign.
 	* malloc/tst-memalign.c: New file.
 
+	* malloc/tst-posix_memalign.c: Add comments.
+	(do_test): Add comments and call free on all potentially
+	allocated pointers. Add space after cast.
+
 2013-10-04  Alan Modra  <amodra@gmail.com>
 
 	* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
diff --git a/malloc/tst-posix_memalign.c b/malloc/tst-posix_memalign.c
index 9d9d1bf..27c0dd2 100644
--- a/malloc/tst-posix_memalign.c
+++ b/malloc/tst-posix_memalign.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2013 Free Software Foundation, Inc.
+/* Test for posix_memalign.
+   Copyright (C) 2013 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
@@ -35,11 +36,13 @@ do_test (void)
 {
   void *p;
   int ret;
-  unsigned long pagesize = getpagesize();
+  unsigned long pagesize = getpagesize ();
   unsigned long ptrval;
 
   p = NULL;
 
+  /* An attempt to allocate a huge value should return ENOMEM and
+     p should remain NULL.  */
   ret = posix_memalign (&p, sizeof (void *), -1);
 
   if (ret != ENOMEM)
@@ -48,15 +51,22 @@ do_test (void)
   if (ret == ENOMEM && p != NULL)
     merror ("returned an error but pointer was modified");
 
+  free (p);
+
   p = NULL;
 
+  /* Test to expose integer overflow in malloc internals from BZ #15857.  */
   ret = posix_memalign (&p, pagesize, -pagesize);
 
   if (ret != ENOMEM)
     merror ("posix_memalign (&p, pagesize, -pagesize) succeeded.");
 
+  free (p);
+
   p = NULL;
 
+  /* A zero-sized allocation should succeed with glibc, returning zero
+     and setting p to a non-NULL value.  */
   ret = posix_memalign (&p, sizeof (void *), 0);
 
   if (ret != 0 || p == NULL)
@@ -84,9 +94,9 @@ do_test (void)
   if (ret == 0 && p == NULL)
     merror ("returned success but pointer is NULL");
 
-  ptrval = (unsigned long)p;
+  ptrval = (unsigned long) p;
 
-  if (ret == 0 && (ptrval & 0xff))
+  if (ret == 0 && (ptrval & 0xff) != 0)
     merror ("pointer is not aligned to 0x100");
 
   free (p);

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=215c7d43444a64fcb571381ebcd39c7514c7b4ff

commit 215c7d43444a64fcb571381ebcd39c7514c7b4ff
Author: Will Newton <will.newton@linaro.org>
Date:   Fri Aug 16 17:06:10 2013 +0100

    malloc: Add memalign test.
    
    ChangeLog:
    
    2013-10-04  Will Newton  <will.newton@linaro.org>
    
        * malloc/Makefile: Add tst-memalign.
        * malloc/tst-memalign.c: New file.

diff --git a/ChangeLog b/ChangeLog
index 0280837..7c26881 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-04  Will Newton  <will.newton@linaro.org>
+
+	* malloc/Makefile: Add tst-memalign.
+	* malloc/tst-memalign.c: New file.
+
 2013-10-04  Alan Modra  <amodra@gmail.com>
 
 	* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
diff --git a/malloc/Makefile b/malloc/Makefile
index 17d146b..d482879 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -27,7 +27,7 @@ headers := $(dist-headers) obstack.h mcheck.h
 tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 	 tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \
 	 tst-malloc-usable tst-realloc tst-posix_memalign \
-	 tst-pvalloc
+	 tst-pvalloc tst-memalign
 test-srcs = tst-mtrace
 
 routines = malloc morecore mcheck mtrace obstack
diff --git a/malloc/tst-memalign.c b/malloc/tst-memalign.c
new file mode 100644
index 0000000..1c59752
--- /dev/null
+++ b/malloc/tst-memalign.c
@@ -0,0 +1,99 @@
+/* Test for memalign.
+   Copyright (C) 2013 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static int errors = 0;
+
+static void
+merror (const char *msg)
+{
+  ++errors;
+  printf ("Error: %s\n", msg);
+}
+
+static int
+do_test (void)
+{
+  void *p;
+  unsigned long pagesize = getpagesize ();
+  unsigned long ptrval;
+  int save;
+
+  errno = 0;
+
+  /* An attempt to allocate a huge value should return NULL and set
+     errno to ENOMEM.  */
+  p = memalign (sizeof (void *), -1);
+
+  save = errno;
+
+  if (p != NULL)
+    merror ("memalign (sizeof (void *), -1) succeeded.");
+
+  if (p == NULL && save != ENOMEM)
+    merror ("memalign (sizeof (void *), -1) errno is not set correctly");
+
+  free (p);
+
+  errno = 0;
+
+  /* Test to expose integer overflow in malloc internals from BZ #15857.  */
+  p = memalign (pagesize, -pagesize);
+
+  save = errno;
+
+  if (p != NULL)
+    merror ("memalign (pagesize, -pagesize) succeeded.");
+
+  if (p == NULL && save != ENOMEM)
+    merror ("memalign (pagesize, -pagesize) errno is not set correctly");
+
+  free (p);
+
+  /* A zero-sized allocation should succeed with glibc, returning a
+     non-NULL value.  */
+  p = memalign (sizeof (void *), 0);
+
+  if (p == NULL)
+    merror ("memalign (sizeof (void *), 0) failed.");
+
+  free (p);
+
+  /* Check the alignment of the returned pointer is correct.  */
+  p = memalign (0x100, 10);
+
+  if (p == NULL)
+    merror ("memalign (0x100, 10) failed.");
+
+  ptrval = (unsigned long) p;
+
+  if ((ptrval & 0xff) != 0)
+    merror ("pointer is not aligned to 0x100");
+
+  free (p);
+
+  return errors != 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                |   19 +++++++++++++
 malloc/Makefile                          |    2 +-
 malloc/{tst-pvalloc.c => tst-memalign.c} |   44 +++++++++++++++++------------
 malloc/tst-posix_memalign.c              |   18 +++++++++---
 malloc/tst-pvalloc.c                     |   20 +++++++++----
 malloc/tst-valloc.c                      |   20 +++++++++----
 6 files changed, 88 insertions(+), 35 deletions(-)
 copy malloc/{tst-pvalloc.c => tst-memalign.c} (55%)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]