Fix memory leak in decode timestamp return
authorTheodore Tso <tytso@mit.edu>
Wed, 21 Sep 1994 20:55:11 +0000 (20:55 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 21 Sep 1994 20:55:11 +0000 (20:55 +0000)
Initialize return variable in decode_krb5_authdata()

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

src/lib/krb5/asn.1/ChangeLog
src/lib/krb5/asn.1/asn1_decode.c
src/lib/krb5/asn.1/krb5_decode.c

index 2dbca546353aba823bc646e631fbc1f49834731d..4413c9643105278c9e7438015a921d8724d23eaf 100644 (file)
@@ -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
index 76304ece60a2493e8e05b9cd29b2f767bc18af6b..40ead94867b563c2cc82608ed7c55c76a56ff646 100644 (file)
@@ -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;
 
index c9f48fb51aec3585a8b36878660c5ae3901902b5..21cde1ddb018fba51e97935f4584e6c4334e0b94 100644 (file)
@@ -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();