krb5 commit: Fix preauth crash on memory exhaustion

ghudson at mit.edu ghudson at mit.edu
Mon Dec 5 16:42:01 EST 2022


https://github.com/krb5/krb5/commit/7736144eb613f797dea57a44da33007a19602e5e
commit 7736144eb613f797dea57a44da33007a19602e5e
Author: ChenChen Zhou <357726167 at qq.com>
Date:   Sun Nov 27 22:24:24 2022 +0800

    Fix preauth crash on memory exhaustion
    
    In k5_preauth_request_context_init(), check the result of calloc().
    
    [ghudson at mit.edu: rewrote commit message; added free() of reqctx on error]
    
    ticket: 9079 (new)

 src/lib/krb5/krb/preauth2.c | 4 ++++
 1 file changed, 4 insertions(+)

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)


More information about the cvs-krb5 mailing list