• Andrew Gabbasov's avatar
    udf: Check output buffer length when converting name to CS0 · e2889463
    Andrew Gabbasov authored
    commit bb00c898 upstream.
    
    If a name contains at least some characters with Unicode values
    exceeding single byte, the CS0 output should have 2 bytes per character.
    And if other input characters have single byte Unicode values, then
    the single input byte is converted to 2 output bytes, and the length
    of output becomes larger than the length of input. And if the input
    name is long enough, the output length may exceed the allocated buffer
    length.
    
    All this means that conversion from UTF8 or NLS to CS0 requires
    checking of output length in order to stop when it exceeds the given
    output buffer size.
    
    [JK: Make code return -ENAMETOOLONG instead of silently truncating the
    name]
    Signed-off-by: default avatarAndrew Gabbasov <andrew_gabbasov@mentor.com>
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    e2889463
unicode.c 11.4 KB