Avoid malloc(0) in ASN.1 bytestring decode
authorGreg Hudson <ghudson@mit.edu>
Sat, 31 Mar 2012 00:38:16 +0000 (00:38 +0000)
committerGreg Hudson <ghudson@mit.edu>
Sat, 31 Mar 2012 00:38:16 +0000 (00:38 +0000)
In k5_asn1_decode_bytestring, just leave *str_out as NULL if len is 0,
instead of calling malloc(0) and possibly returning a spurious ENOMEM.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25796 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/asn1_encode.c

index 51fd8eeabfe427872ad499712f577d246dc16fd4..395831c1ad64a2530803b7dd3413c4adbcebcf5e 100644 (file)
@@ -234,6 +234,8 @@ k5_asn1_decode_bytestring(const unsigned char *asn1, size_t len,
 
     *str_out = NULL;
     *len_out = 0;
+    if (len == 0)
+        return 0;
     str = malloc(len);
     if (str == NULL)
         return ENOMEM;