mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
ITS#6215: Fix buffer overrun and write through NULL pointer
This commit is contained in:
parent
8a0284cf04
commit
12a6f3e055
@ -129,9 +129,13 @@ ber_realloc( BerElement *ber, ber_len_t len )
|
||||
char *oldbuf;
|
||||
|
||||
assert( ber != NULL );
|
||||
assert( len > 0 );
|
||||
assert( LBER_VALID( ber ) );
|
||||
|
||||
/* leave room for ber_flatten() to \0-terminate ber_buf */
|
||||
if ( ++len == 0 ) {
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
total = ber_pvt_ber_total( ber );
|
||||
|
||||
#define LBER_EXBUFSIZ 4060 /* a few words less than 2^N for binary buddy */
|
||||
@ -415,10 +419,13 @@ int ber_flatten2(
|
||||
return -1;
|
||||
}
|
||||
AC_MEMCPY( bv->bv_val, ber->ber_buf, len );
|
||||
} else {
|
||||
bv->bv_val[len] = '\0';
|
||||
} else if ( ber->ber_buf != NULL ) {
|
||||
bv->bv_val = ber->ber_buf;
|
||||
bv->bv_val[len] = '\0';
|
||||
} else {
|
||||
bv->bv_val = "";
|
||||
}
|
||||
bv->bv_val[len] = '\0';
|
||||
bv->bv_len = len;
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user