bug-libunistring
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-libunistring] Segmentation fault using u8_grapheme_prev with malfor


From: Vincent Westenberg
Subject: [bug-libunistring] Segmentation fault using u8_grapheme_prev with malformed UTF-8 string
Date: Thu, 2 Dec 2021 16:36:00 +0000

Hello!

I have noticed a strange behavior using the function
`u8_grapheme_prev`. Given a malformed UTF-8 string
it causes a segmentation fault error.

-----------------------------------------------------

#include <string.h>
#include <unigbrk.h>

int main()
{
    uint8_t *s = "foo\xff";      /* \xff invalid byte */
    uint8_t *s_ = s + strlen(s);
    const uint8_t *prev = u8_grapheme_prev(s_, s);
    return 0;
}

-----------------------------------------------------

$ gcc test.c -o test -lunistring
$ ./test
Segmentation fault (core dumped)
$ echo $?
139

-----------------------------------------------------

OS: GNU/Linux (Manjaro)
ARCH: x86_64
libunistring: 0.9.10
gcc: 11.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]