Skip to content

Commit ecad8c6

Browse files
committed
Fix buffer size for utf8toUnicode transformation
1 parent 454669f commit ecad8c6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
v3.0.4 - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4-
4+
* Fix buffer size for utf8toUnicode transformation
5+
[Issue #1208 - @katef, @victorhora]
56

67

78
v3.0.3 - 2018-Nov-05

src/actions/transformations/utf8_to_unicode.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ char *Utf8ToUnicode::inplace(unsigned char *input,
7272
unsigned char unicode[8];
7373
*changed = 0;
7474

75-
len = input_len * 7 + 1;
75+
/* RFC3629 states that UTF-8 are encoded using sequences of 1 to 4 octets. */
76+
/* Max size per character should fit in 4 bytes */
77+
len = input_len * 4 + 1;
7678
data = reinterpret_cast<char *>(malloc(sizeof(char) * len));
7779
if (data == NULL) {
7880
return NULL;

0 commit comments

Comments
 (0)