This is the mail archive of the glibc-bugs@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]

[Bug string/19667] New: Missing Sanity Check for malloc calls in file 'testcopy.c'


https://sourceware.org/bugzilla/show_bug.cgi?id=19667

            Bug ID: 19667
           Summary: Missing Sanity Check for malloc calls in file
                    'testcopy.c'
           Product: glibc
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: string
          Assignee: unassigned at sourceware dot org
          Reporter: wp02855 at gmail dot com
  Target Milestone: ---

Created attachment 9005
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9005&action=edit
patch file for above bug report (diff -u)

In directory 'glibc-2.22/string', file 'testcopy.c', there are calls to
malloc() which are not checked for a return value of NULL, indicating
failure.

The patch file below should address/correct this issue:

--- testcopy.c.orig     2016-02-18 08:23:39.328682016 -0800
+++ testcopy.c  2016-02-18 08:26:48.575734343 -0800
@@ -38,6 +38,13 @@
   rand_mem = malloc (max_size);
   lo_around = malloc (space_around);
   hi_around = malloc (space_around);
+  if ((mem == NULL) || (randmem == NULL) ||
+      (lo_around == NULL) || (hi_around == NULL))
+    {
+      puts("Unable to allocate memory for test...");
+      abort ();
+    }
+
   memp = mem + space_around;

   /* Fill RAND_MEM with random bytes, each non-zero.  */

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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