]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix preauth crash on memory exhaustion 1274/head
authorChenChen Zhou <357726167@qq.com>
Sun, 27 Nov 2022 14:24:24 +0000 (22:24 +0800)
committerGreg Hudson <ghudson@mit.edu>
Mon, 5 Dec 2022 18:35:40 +0000 (13:35 -0500)
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)

src/lib/krb5/krb/preauth2.c

index ffca476c2bfedeeb41826388f726cb50199e7c68..32f35b76158a67fe715df6b71bcac8482cc35664 100644 (file)
@@ -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)