ghostutils: Limit punycode decoding output length

It uses a `GArray` to build up the output, and the size of that is
limited to a `guint`, so add an assertion to make sure the code never
requests anything bigger.

Fixes a `-Wshorten-64-to-32` warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3527
This commit is contained in:
Philip Withnall 2024-11-07 14:08:11 +00:00
parent e35aa61a55
commit a6c36498ed
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -35,6 +35,7 @@
#include "gmessages.h"
#include "gstring.h"
#include "gstrfuncs.h"
#include "gtestutils.h"
#include "glibintl.h"
#ifdef G_PLATFORM_WIN32
@ -587,8 +588,10 @@ punycode_decode (const gchar *input,
split--;
if (split > input)
{
g_assert ((guint) (split - input) <= G_MAXUINT);
output_chars = g_array_sized_new (FALSE, FALSE, sizeof (gunichar),
split - input);
(guint) (split - input));
input_length -= (split - input) + 1;
while (input < split)
{