]> granicus.if.org Git - php/commitdiff
Fix a NULL dereferencing crash in php-ldap
authorCôme Chilliet <mcmic@php.net>
Mon, 15 Apr 2019 08:16:29 +0000 (10:16 +0200)
committerCôme Chilliet <mcmic@php.net>
Mon, 15 Apr 2019 08:16:29 +0000 (10:16 +0200)
This happens when parsing a control response to a VLV request which does
 not contain a "context" string.

See bug #77869

ext/ldap/ldap.c

index 35e0c06e8226ade9235d8591217c9c73fd935aaa..55a215a587742d4d93cc2f24489fe781c05cfcac 100644 (file)
@@ -259,7 +259,9 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array,
                        add_assoc_long(&value, "target", target);
                        add_assoc_long(&value, "count", count);
                        add_assoc_long(&value, "errcode", errcode);
-                       add_assoc_stringl(&value, "context", context->bv_val, context->bv_len);
+                       if ( context && (context->bv_len >= 0) ) {
+                               add_assoc_stringl(&value, "context", context->bv_val, context->bv_len);
+                       }
                        add_assoc_zval(array, "value", &value);
                } else {
                        add_assoc_null(array, "value");