From: Theodore Tso Date: Wed, 21 Sep 1994 20:55:11 +0000 (+0000) Subject: Fix memory leak in decode timestamp return X-Git-Tag: krb5-1.0-beta4.3~103 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=787858e0528df604a6e88abe19f7b3fff76f3502;p=krb5.git Fix memory leak in decode timestamp return Initialize return variable in decode_krb5_authdata() git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4327 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 2dbca5463..4413c9643 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,12 @@ +Wed Sep 21 00:18:12 1994 Theodore Y. Ts'o (tytso@dcl) + + * krb5_decode.c (decode_krb5_authdata): Initialize variable where + the authdata is returned to NULL first. (Caller shouldn't + have to do this.) + + * asn1_decode.c (asn1_decode_generaltime): Plug memory leak caused + by not freeing temporary string. + Wed Aug 17 16:07:06 1994 Theodore Y. Ts'o (tytso at tsx-11) * krb5_encode.c (encode_krb5_enc_kdc_rep_part): Older versions of diff --git a/src/lib/krb5/asn.1/asn1_decode.c b/src/lib/krb5/asn.1/asn1_decode.c index 76304ece6..40ead9486 100644 --- a/src/lib/krb5/asn.1/asn1_decode.c +++ b/src/lib/krb5/asn.1/asn1_decode.c @@ -191,7 +191,10 @@ asn1_error_code asn1_decode_generaltime(DECLARG(asn1buf *, buf), if(length != 15) return ASN1_BAD_LENGTH; retval = asn1buf_remove_charstring(buf,15,&s); /* Time encoding: YYYYMMDDhhmmssZ */ - if(s[14] != 'Z') return ASN1_BAD_FORMAT; + if(s[14] != 'Z') { + free(s); + return ASN1_BAD_FORMAT; + } #define c2i(c) ((c)-'0') ts.tm_year = 1000*c2i(s[0]) + 100*c2i(s[1]) + 10*c2i(s[2]) + c2i(s[3]) - 1900; @@ -202,6 +205,7 @@ asn1_error_code asn1_decode_generaltime(DECLARG(asn1buf *, buf), ts.tm_sec = 10*c2i(s[12]) + c2i(s[13]); ts.tm_isdst = -1; t = gmt_mktime(&ts); + free(s); if(t == -1) return ASN1_BAD_TIMEFORMAT; diff --git a/src/lib/krb5/asn.1/krb5_decode.c b/src/lib/krb5/asn.1/krb5_decode.c index c9f48fb51..21cde1ddb 100644 --- a/src/lib/krb5/asn.1/krb5_decode.c +++ b/src/lib/krb5/asn.1/krb5_decode.c @@ -592,6 +592,7 @@ krb5_error_code decode_krb5_authdata(DECLARG(const krb5_data *, code), OLDDECLARG(krb5_authdata ***, rep) { setup_buf_only(); + *rep = 0; retval = asn1_decode_authorization_data(&buf,rep); if(retval) return (krb5_error_code)retval; cleanup();