X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=ldif.c;h=617cefceaca0ea6da9ae178dbfcb9d4578f10899;hb=24be624311cedd42ed09acfc605cdf51546bb5ab;hp=9a69f12632a9612a386ffba94621b369a4a2fec5;hpb=0d3c17d9ab127e5596c8fb97d65122b3b90f6b11;p=pkg%2Fabook.git diff --git a/ldif.c b/ldif.c index 9a69f12..617cefc 100644 --- a/ldif.c +++ b/ldif.c @@ -1,6 +1,6 @@ /* - * adapted to use with abook by JH + * adapted to use with abook by JH */ /* @@ -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;