[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] An interesting bug with clock() in debug mode
From: |
Stefanos |
Subject: |
Re: [Tinycc-devel] An interesting bug with clock() in debug mode |
Date: |
Thu, 24 Nov 2022 00:03:52 +0200 |
Yeah, I did not think of using the `-fsanitize` flag with GCC or clang; good
catch Rob.
First I saw this line `strncat(dst + len, src, sizeof(dst) - len - 1);`
and thought as you that will overflow due to the limination of 24 bytes;
then I decided to double-check with man pages and have found this:
`char *strncat(char *restrict dest, const char *restrict src, size_t n);`
So, silly me thought it was some kind of pointer magic that could possibly
work behind the scenes (?), but 24 bytes and then 26 characters should have
made it quite obvious it *is* an actual overflow, regardless of line
`strncat(dst + len, src, sizeof(dst) - len - 1);`.
Oh well...
Today I was reminded of using my sanitizer flag more often lol.
Thank you Rob.