X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=ldif.c;h=617cefceaca0ea6da9ae178dbfcb9d4578f10899;hb=c5d8ef5198f2bfd02f678b7a709b6538ef83cd44;hp=46230ad6af853dfa93610349188a4f317ace46b3;hpb=7dca83329bb3ce545d6d03e10754999b9a82ca01;p=pkg%2Fabook.git diff --git a/ldif.c b/ldif.c index 46230ad..617cefc 100644 --- a/ldif.c +++ b/ldif.c @@ -327,10 +327,16 @@ ldif_type_and_value( char *type, char *val, int vlen ) { char *buf, *p; int tlen; + size_t bufsize, t; tlen = strlen( type ); - if (( buf = (char *)malloc( LDIF_SIZE_NEEDED( tlen, vlen ) + 1 )) != - NULL ) { + + t = LDIF_SIZE_NEEDED( tlen, vlen ); + if((bufsize = t + 1) <= t) + return NULL; + + if (( buf = (char *)malloc( bufsize )) == NULL ) { + return NULL; } p = buf;