forked from enlightenment/efl
address non nul terminated string due to strncpy
this addresses CID 1230994. as such eina_unicode_unicode_to_utf8() always returns a nul terminated string. so it's guaranteed. but yes - if string is 7 bytes or longer it will not put a nul byte on the destination. as such for a single unicode char this can never happen as in utf8 it's 6 bytes. but since eina_unicode_unicode_to_utf8() safely returns a nul terminated string at all times - we can just use strcpy safely. no need for strncpy. also handle null return from eina_unicode_unicode_to_utf8()
This commit is contained in:
parent
2ac4f520d6
commit
d539152156
|
@ -6137,8 +6137,13 @@ _escaped_char_get(const char *s, const char *s_end)
|
|||
return NULL;
|
||||
|
||||
utf8_char = eina_unicode_unicode_to_utf8(uchar, NULL);
|
||||
strncpy(utf8_escape, utf8_char, sizeof(utf8_escape));
|
||||
// eina_unicode_unicode_to_utf8() always creates a string that
|
||||
// is nul terminated - guaranteed
|
||||
if (utf8_char)
|
||||
{
|
||||
strcpy(utf8_escape, utf8_char);
|
||||
free(utf8_char);
|
||||
}
|
||||
|
||||
return utf8_escape;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue