[glibc] stdio-common: Fix overflow registering modifier [BZ #34086]

Adhemerval Zanella via Glibc-cvs <[email protected]>
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4fd40bba95f666470b5e40ed6aca641f5e46d2e6

commit 4fd40bba95f666470b5e40ed6aca641f5e46d2e6
Author: Rocket Ma <[email protected]>
Date:   Thu Apr 23 09:09:23 2026 -0700

    stdio-common: Fix overflow registering modifier [BZ #34086]
    
    * stdio-common/reg-modifier.c: The wchar in str can be greater or equal
    than 0, and less or equal than UCHAR_MAX, that means, we need a buffer
    with UCHAR_MAX + 1 elements, so that user input will not overflow
    __printf_modifier_table.
    
    Signed-off-by: Rocket Ma <[email protected]>
    Reviewed-by: Adhemerval Zanella  <[email protected]>

Diff:
---
 stdio-common/reg-modifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stdio-common/reg-modifier.c b/stdio-common/reg-modifier.c
index 60d0521527..367f482bd5 100644
--- a/stdio-common/reg-modifier.c
+++ b/stdio-common/reg-modifier.c
@@ -66,7 +66,7 @@ __register_printf_modifier (const wchar_t *str)
 
   if (__printf_modifier_table == NULL)
     {
-      __printf_modifier_table = calloc (UCHAR_MAX,
+      __printf_modifier_table = calloc (UCHAR_MAX + 1,
 					sizeof (*__printf_modifier_table));
       if (__printf_modifier_table == NULL)
 	goto out;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.