summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChenChen Zhou <357726167@qq.com>2022-11-27 22:24:24 +0800
committerGreg Hudson <ghudson@mit.edu>2022-12-05 13:35:40 -0500
commit7736144eb613f797dea57a44da33007a19602e5e (patch)
treecec67db2e1f9073c52f8ff96cb5b6021be5e46d6
parent2929ec400c174bc848a9c438a61b0e3506b91d0e (diff)
downloadkrb5-7736144eb613f797dea57a44da33007a19602e5e.tar.gz
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)
-rw-r--r--src/lib/krb5/krb/preauth2.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/krb5/krb/preauth2.c b/src/lib/krb5/krb/preauth2.c
index ffca476c2..32f35b761 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)