diff options
author | Charles Fol <folcharles@gmail.com> | 2024-03-28 12:25:38 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-04-17 09:21:40 -0300 |
commit | f9dc609e06b1136bb0408be9605ce7973a767ada (patch) | |
tree | 037b3b21761d32ad3aa4c25907075959c4ed5508 /iconvdata/iso-2022-cn-ext.c | |
parent | 59974938fe1f4add843f5325f78e2a7ccd8db853 (diff) | |
download | glibc-f9dc609e06b1136bb0408be9605ce7973a767ada.zip glibc-f9dc609e06b1136bb0408be9605ce7973a767ada.tar.gz glibc-f9dc609e06b1136bb0408be9605ce7973a767ada.tar.bz2 |
iconv: ISO-2022-CN-EXT: fix out-of-bound writes when writing escape sequence (CVE-2024-2961)
ISO-2022-CN-EXT uses escape sequences to indicate character set changes
(as specified by RFC 1922). While the SOdesignation has the expected
bounds checks, neither SS2designation nor SS3designation have its;
allowing a write overflow of 1, 2, or 3 bytes with fixed values:
'$+I', '$+J', '$+K', '$+L', '$+M', or '$*H'.
Checked on aarch64-linux-gnu.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'iconvdata/iso-2022-cn-ext.c')
-rw-r--r-- | iconvdata/iso-2022-cn-ext.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/iconvdata/iso-2022-cn-ext.c b/iconvdata/iso-2022-cn-ext.c index b34c8a3..cce29b1 100644 --- a/iconvdata/iso-2022-cn-ext.c +++ b/iconvdata/iso-2022-cn-ext.c @@ -574,6 +574,12 @@ DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); { \ const char *escseq; \ \ + if (outptr + 4 > outend) \ + { \ + result = __GCONV_FULL_OUTPUT; \ + break; \ + } \ + \ assert (used == CNS11643_2_set); /* XXX */ \ escseq = "*H"; \ *outptr++ = ESC; \ @@ -587,6 +593,12 @@ DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized"); { \ const char *escseq; \ \ + if (outptr + 4 > outend) \ + { \ + result = __GCONV_FULL_OUTPUT; \ + break; \ + } \ + \ assert ((used >> 5) >= 3 && (used >> 5) <= 7); \ escseq = "+I+J+K+L+M" + ((used >> 5) - 3) * 2; \ *outptr++ = ESC; \ |