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 libc/19672] New: Missing Sanity Check for malloc() in file 'tst-utmp.c'


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

            Bug ID: 19672
           Summary: Missing Sanity Check for malloc() in file 'tst-utmp.c'
           Product: glibc
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: wp02855 at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

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

In directory 'login', file 'tst-utmp.c', there is a call to malloc()
which is not checked for a return value of NULL, indicating failure.

The patch file below should address/correct this issue:

--- tst-utmp.c.orig     2016-02-17 16:24:43.858095625 -0800
+++ tst-utmp.c  2016-02-17 16:26:16.360852249 -0800
@@ -63,6 +63,9 @@

   name_len = strlen (test_dir);
   name = malloc (name_len + sizeof ("/utmpXXXXXX"));
+  if (name == NULL)
+    error (EXIT_FAILURE, errno, "unable to allocate memory for test");
+
   mempcpy (mempcpy (name, test_dir, name_len),
           "/utmpXXXXXX", sizeof ("/utmpXXXXXX"));
   add_temp_file (name);

-- 
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]