Closed tonymarklove closed 6 years ago
Here is an example test case where I tell utf8ncpy to write at most 10 bytes, but results in all 11 bytes of the buffer being written. I first noticed this in a larger program when it triggered a stack check exception due to buffer overflow.
utf8ncpy
#include <string.h> #include <stdio.h> #include "utf8.h" int main(int argc, char* argv[]) { char buffer[11]; memset(buffer, 0xdd, 11); printf("%02x\n", buffer[10] & 0xff); utf8ncpy(buffer, "foo", 10); printf("%02x\n", buffer[10] & 0xff); }
which I have compiled simply with clang main.c with clang version: Apple LLVM version 9.1.0 (clang-902.0.39.2)
clang main.c
I get the result of
dd 00
when I would expect
dd dd
Good find! Got a fix in testing 😄
Excellent. Thanks for the speedy update. 🙂
Here is an example test case where I tell
utf8ncpy
to write at most 10 bytes, but results in all 11 bytes of the buffer being written. I first noticed this in a larger program when it triggered a stack check exception due to buffer overflow.which I have compiled simply with
clang main.c
with clang version: Apple LLVM version 9.1.0 (clang-902.0.39.2)I get the result of
when I would expect