[glibc/azanella/ubsan-undef] libio: Fix UB __libio_codecvt_length
Adhemerval Zanella
azanella@sourceware.org
Fri Apr 25 19:53:38 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=49431f65444e82c01bd9a5301bdd1bb61169c922
commit 49431f65444e82c01bd9a5301bdd1bb61169c922
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Apr 22 09:02:54 2025 -0300
libio: Fix UB __libio_codecvt_length
To avoid a 0 size VLA.
Diff:
---
libio/iofwide.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libio/iofwide.c b/libio/iofwide.c
index c00b83c703..e9d6e51ac7 100644
--- a/libio/iofwide.c
+++ b/libio/iofwide.c
@@ -228,6 +228,9 @@ __libio_codecvt_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
const char *from_start, const char *from_end,
size_t max)
{
+ if (max == 0)
+ return 0;
+
int result;
const unsigned char *cp = (const unsigned char *) from_start;
wchar_t to_buf[max];
More information about the Glibc-cvs
mailing list