size check before allocating

This commit is contained in:
Christian Grothoff
2026-07-08 11:51:55 +02:00
parent b2752fc496
commit e5f88887df
+9 -9
View File
@@ -2470,21 +2470,21 @@ psk_gnutls_adapter (gnutls_session_t session,
&app_psk,
&app_psk_size))
return -1;
if (UINT_MAX < app_psk_size)
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
_ ("PSK authentication failed: PSK too long.\n"));
#endif
free (app_psk);
return -1;
}
if (NULL == (key->data = gnutls_malloc (app_psk_size)))
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
_ ("PSK authentication failed: gnutls_malloc failed to " \
"allocate memory.\n"));
#endif
free (app_psk);
return -1;
}
if (UINT_MAX < app_psk_size)
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
_ ("PSK authentication failed: PSK too long.\n"));
#endif
free (app_psk);
return -1;