mirror of https://github.com/nirenjan/libx52.git
fix: Fix boundary check error in libx52util
Prior to this change, if the input string terminates exactly when `len` characters have been output, the libx52util_convert_utf8_string function returns an error of `-E2BIG`, even though the buffer is sufficiently large. Because the output buffer is not expected to be NUL terminated, this additional character can be safely placed in the output buffer without overrun. This change checks for a non-NUL character when the index matches or exceeds the output buffer length, and only then will it return -E2BIG.pull/58/head
parent
762a3468b2
commit
2378ba7dc4
|
|
@ -48,7 +48,7 @@ int libx52util_convert_utf8_string(const uint8_t *input,
|
|||
if (entry->type == TYPE_ENTRY) {
|
||||
output[index] = entry->value;
|
||||
index++;
|
||||
if (index >= *len) {
|
||||
if (index >= *len && *input) {
|
||||
retval = -E2BIG;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue