Commit 1bf57b5a by Patrick Steinhardt

tests: iterator::workdir: fix GCC warning

Since GCC 8.1, the compiler performs some bounds checking when
copying static data into arrays with a known size. In one test,
we print a format string of "%s/sub%02d" into a buffer of 64
bytes. The input buffer for the first "%s" is bounded to at most
63 characters, plus four bytes for the static string "/sub" plus
two more bytes for "%02d". Thus, our target buffer needs to be at
least 70 bytes in size, including the NUL byte. There seems to be
a bug in the analysis, though, because GCC will not account for
the limiting "%02" prefix, treating it as requiring the same
count of bytes as a "%d".

Thus, we end up at 79 bytes that are required to fix the
warning. To make it look nicer and less special, we just round
the buffer size up to 80 bytes.
parent 0750d0cc
......@@ -460,7 +460,7 @@ void test_iterator_workdir__icase_starts_and_ends(void)
static void build_workdir_tree(const char *root, int dirs, int subs)
{
int i, j;
char buf[64], sub[64];
char buf[64], sub[80];
for (i = 0; i < dirs; ++i) {
if (i % 2 == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment