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
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;
pa->length = 0;
pa->pa_type = KRB5_ENCPADATA_REQ_ENC_PA_REP;
pad[size] = pa;
- *padptr = pad;
return 0;
}