]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10488 Avoid out-of-bounds reads
authorOndřej Kuzník <ondra@mistotebe.net>
Wed, 29 Apr 2026 12:53:37 +0000 (13:53 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 29 Apr 2026 16:49:32 +0000 (16:49 +0000)
servers/slapd/result.c

index 441a54a8f94c1a90bed0c68bbea959315ce7f183..ad7abdf5356b918e90ad640b90b6c6d88b92205a 100644 (file)
@@ -89,7 +89,7 @@ static char *v2ref( BerVarray ref, const char *text )
                }
        }
        
-       if ( text != NULL ) {
+       if ( text != NULL && *text != '\0' ) {
                len = strlen( text );
                if (text[len-1] != '\n') {
                    i = 1;
@@ -107,7 +107,8 @@ static char *v2ref( BerVarray ref, const char *text )
        strcpy( v2+len, "Referral:" );
        len += sizeof("Referral:");
 
-       for( i=0; ref[i].bv_val != NULL; i++ ) {
+       for( i=0; !BER_BVISNULL( &ref[i] ) ; i++ ) {
+               if ( BER_BVISEMPTY( &ref[i] ) ) continue;
                v2 = ch_realloc( v2, len + ref[i].bv_len + 1 );
                v2[len-1] = '\n';
                AC_MEMCPY(&v2[len], ref[i].bv_val, ref[i].bv_len );