From: Greg Hudson Date: Sat, 31 Mar 2012 00:38:16 +0000 (+0000) Subject: Avoid malloc(0) in ASN.1 bytestring decode X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4ce0974b4d5c37b22ceedb5aa7115eedcfc486ef;p=krb5.git Avoid malloc(0) in ASN.1 bytestring decode 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 --- diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c index 51fd8eeab..395831c1a 100644 --- a/src/lib/krb5/asn.1/asn1_encode.c +++ b/src/lib/krb5/asn.1/asn1_encode.c @@ -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;