[glib/glib-2-64: 3/7] glib-unix.c: fix heap corruption in g_unix_get_passwd_entry
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [glib/glib-2-64: 3/7] glib-unix.c: fix heap corruption in g_unix_get_passwd_entry
- Date: Fri,  3 Apr 2020 16:42:47 +0000 (UTC)
commit 4d95cb5cb6f88d84d9fda6e8ce15e5ff48494546
Author: Alexander Kanavin <alex kanavin gmail com>
Date:   Wed Apr 1 00:51:39 2020 +0200
    glib-unix.c: fix heap corruption in g_unix_get_passwd_entry
    
    malloc() was given too small value (size of pointer,
    rather than struct it points to), and subsequent call
    getpwnam_r() wrote past the end of allocated block - easily
    seen with valgrind.
    
    Signed-off-by: Alexander Kanavin <alex kanavin gmail com>
 glib/glib-unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glib/glib-unix.c b/glib/glib-unix.c
index 87fa57ae8..608fbd6e6 100644
--- a/glib/glib-unix.c
+++ b/glib/glib-unix.c
@@ -485,7 +485,7 @@ g_unix_get_passwd_entry (const gchar  *user_name,
        * loop until it’s big enough). Add 6 extra bytes to work around a bug in
        * macOS < 10.3. See #156446.
        */
-      buffer = g_malloc0 (sizeof (buffer) + string_buffer_size + 6);
+      buffer = g_malloc0 (sizeof (*buffer) + string_buffer_size + 6);
 
       errno = 0;
       retval = getpwnam_r (user_name, &buffer->pwd, buffer->string_buffer,
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]