1From b0537ec9a7047d55d365a64e9ec9559cf1f28792 Mon Sep 17 00:00:00 2001
2From: David Tardon <dtardon@redhat.com>
3Date: Mon, 13 Nov 2017 16:56:23 +0100
4Subject: [PATCH] avoid target buffer overflow
5
6---
7 icu4c/source/common/ucnv_u8.cpp | 5 +++++
8 1 file changed, 5 insertions(+)
9
10diff --git a/icu4c/source/common/ucnv_u8.cpp b/icu4c/source/common/ucnv_u8.cpp
11index 951988ed9..caaf18ae3 100644
12--- a/icu4c/source/common/ucnv_u8.cpp
13+++ b/icu4c/source/common/ucnv_u8.cpp
14@@ -770,6 +770,11 @@ ucnv_UTF8FromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
15             oldToULength=0;
16             toULength=1;
17             toULimit=U8_COUNT_BYTES_NON_ASCII(b);
18+            if (toULimit > (const uint8_t *)pFromUArgs->targetLimit - target)
19+            {
20+                *pErrorCode = U_BUFFER_OVERFLOW_ERROR;
21+                break;
22+            }
23             c=b;
24 moreBytes:
25             while(toULength<toULimit) {
26--
272.14.1
28
29