/*
- * adapted to use with abook by JH <jheinonen@bigfoot.com>
+ * adapted to use with abook by JH <jheinonen@users.sourceforge.net>
*/
/*
{
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;