msgfmt: Don't overflow the stack with large values for --alignment.

Reported by <maxtodeath@gmail.com> at <https://savannah.gnu.org/bugs/?67743>.

* gettext-tools/src/write-mo.c (write_table): Use xmalloca instead of
alloca to allocate the buffer to fill with NUL bytes.
This commit is contained in:
Collin Funk 2025-12-31 19:11:47 +01:00 committed by Bruno Haible
parent c979c72860
commit 969c026038

View File

@ -1010,7 +1010,7 @@ write_table (FILE *output_file, message_list_ty *mlp)
offset = end_offset;
/* A few zero bytes for padding. */
char *null = (char *) alloca (alignment);
char *null = (char *) xmalloca (alignment);
memset (null, '\0', alignment);
/* Now write the original strings. */