From: ChenChen Zhou <357726167@qq.com> Date: Sun, 27 Nov 2022 14:24:24 +0000 (+0800) Subject: Fix preauth crash on memory exhaustion X-Git-Tag: krb5-1.21-beta1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7736144eb613f797dea57a44da33007a19602e5e;p=thirdparty%2Fkrb5.git Fix preauth crash on memory exhaustion In k5_preauth_request_context_init(), check the result of calloc(). [ghudson@mit.edu: rewrote commit message; added free() of reqctx on error] ticket: 9079 (new) --- diff --git a/src/lib/krb5/krb/preauth2.c b/src/lib/krb5/krb/preauth2.c index ffca476c2b..32f35b7615 100644 --- a/src/lib/krb5/krb/preauth2.c +++ b/src/lib/krb5/krb/preauth2.c @@ -263,6 +263,10 @@ k5_preauth_request_context_init(krb5_context context, * preauth context's array of handles. */ for (count = 0; pctx->handles[count] != NULL; count++); reqctx->modreqs = calloc(count, sizeof(*reqctx->modreqs)); + if (reqctx->modreqs == NULL) { + free(reqctx); + return; + } for (i = 0; i < count; i++) { h = pctx->handles[i]; if (h->vt.request_init != NULL)