]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix unlikely pointer error in get_in_tkt.c
authorGreg Hudson <ghudson@mit.edu>
Mon, 9 May 2016 17:45:06 +0000 (13:45 -0400)
committerTom Yu <tlyu@mit.edu>
Wed, 6 Jul 2016 19:17:06 +0000 (15:17 -0400)
In add_padata(), reset the caller's pointer and ensure the list is
terminated as soon as realloc() succeeds; otherwise, the old pointer
could be left behind if a later allocation fails.

(cherry picked from commit 24452cd737951fa6e0f35e97c6a644a9db0aa82d)

ticket: 8413
version_fixed: 1.13.6
tags: -pullup
status: resolved

src/lib/krb5/krb/get_in_tkt.c

index 7a50161bb6edffeeacb6d891a58bd9f82c6edef3..4ec4e5542f3cccc03d4fff7c83700e1977349998 100644 (file)
@@ -342,10 +342,11 @@ request_enc_pa_rep(krb5_pa_data ***padptr)
     if (pad)
         for (size=0; pad[size]; size++);
     pad = realloc(pad, sizeof(*pad)*(size+2));
-
     if (pad == NULL)
         return ENOMEM;
-    pad[size+1] = NULL;
+    *padptr = pad;
+    pad[size] = pad[size + 1] = NULL;
+
     pa = malloc(sizeof(krb5_pa_data));
     if (pa == NULL)
         return ENOMEM;
@@ -353,7 +354,6 @@ request_enc_pa_rep(krb5_pa_data ***padptr)
     pa->length = 0;
     pa->pa_type = KRB5_ENCPADATA_REQ_ENC_PA_REP;
     pad[size] = pa;
-    *padptr = pad;
     return 0;
 }