commit e5f88887dfcb3eb36f9028b031fb6f932d7538be parent b2752fc496218723dd76c1c94ec88be39fca0577 Author: Christian Grothoff <grothoff@gnunet.org> Date: Wed, 8 Jul 2026 11:51:55 +0200 size check before allocating Diffstat:
| M | src/microhttpd/daemon.c | | | 10 | +++++----- |
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2470,21 +2470,21 @@ psk_gnutls_adapter (gnutls_session_t session, &app_psk, &app_psk_size)) return -1; - if (NULL == (key->data = gnutls_malloc (app_psk_size))) + if (UINT_MAX < app_psk_size) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, - _ ("PSK authentication failed: gnutls_malloc failed to " \ - "allocate memory.\n")); + _ ("PSK authentication failed: PSK too long.\n")); #endif free (app_psk); return -1; } - if (UINT_MAX < app_psk_size) + if (NULL == (key->data = gnutls_malloc (app_psk_size))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, - _ ("PSK authentication failed: PSK too long.\n")); + _ ("PSK authentication failed: gnutls_malloc failed to " \ + "allocate memory.\n")); #endif free (app_psk); return -1;