]> granicus.if.org Git - php/commitdiff
Fixed bug #72133 (php_posix_group_to_array crashes if gr_passwd is NULL)
authorXinchen Hui <laruence@gmail.com>
Sun, 1 May 2016 03:00:41 +0000 (11:00 +0800)
committerXinchen Hui <laruence@gmail.com>
Sun, 1 May 2016 03:00:41 +0000 (11:00 +0800)
NEWS
ext/posix/posix.c

diff --git a/NEWS b/NEWS
index 1df7cecc1959a15749d8c7bc211840fa01edca07..4a807c48eeb874383db9a69e38791a5dd081e9ae 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,10 @@ PHP                                                                        NEWS
   . Fixed bug #72014 (Including a file with anonymous classes multiple times
     leads to fatal error). (Laruence)
 
+- POSIX:
+  . Fixed bug #72133 (php_posix_group_to_array crashes if gr_passwd is NULL).
+    (esminis at esminis dot lt)
+
 - Postgres:
   . Fixed bug #72028 (pg_query_params(): NULL converts to empty string).
     (Laruence)
index e1f4ef62622ef222ff6df750254ece3184fd53ef..25cb26f372c1ea62cfdd79d532f503cbf1fb3004 100644 (file)
@@ -987,8 +987,12 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */
        array_init(&array_members);
 
        add_assoc_string(array_group, "name", g->gr_name);
-       add_assoc_string(array_group, "passwd", g->gr_passwd);
-       for (count=0; g->gr_mem[count] != NULL; count++) {
+       if (array_group->gr_passwd) {
+               add_assoc_string(array_group, "passwd", g->gr_passwd);
+       } else {
+               add_assoc_null(array_group, "passwd");
+       }
+       for (count = 0; g->gr_mem[count] != NULL; count++) {
                add_next_index_string(&array_members, g->gr_mem[count]);
        }
        zend_hash_str_update(Z_ARRVAL_P(array_group), "members", sizeof("members")-1, &array_members);