]> git.deb.at Git - pkg/abook.git/blobdiff - ldif.c
Imported Upstream version 0.5.3
[pkg/abook.git] / ldif.c
diff --git a/ldif.c b/ldif.c
index 46230ad6af853dfa93610349188a4f317ace46b3..617cefceaca0ea6da9ae178dbfcb9d4578f10899 100644 (file)
--- 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;