ble_ctf_infinity icon indicating copy to clipboard operation
ble_ctf_infinity copied to clipboard

Compilation catches strcpy overflow

Open PhatHub opened this issue 5 years ago • 1 comments

When running make to compile, there is a strcpy overflow caught in flag_scoreboard.c

Error is below:

CC build/main/flag_scoreboard.o /home/user/esp/ble_ctf_infinity/main/flag_scoreboard.c: In function 'flag_scoreboard_main': /home/user/esp/ble_ctf_infinity/main/flag_scoreboard.c:891:1: error: '__builtin_memcpy' writing 3 bytes into a region of size 2 overflows the destination [-Werror=stringop-overflow=] strcpy(string_total_flags, "10"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors /home/user/esp/esp-idf/make/component_wrapper.mk:291: recipe for target 'flag_scoreboard.o' failed make[1]: *** [flag_scoreboard.o] Error 1 /home/user/esp/esp-idf/make/project.mk:635: recipe for target 'component-main-build' failed make: *** [component-main-build] Error 2

I wasn't sure if this was supposed to be a memory overflow puzzle... but to get the compilation to complete, I made a small change. In line 191 of flag_scoreboard.c I changed string_total_flags to a 3-byte string by adding an additional nul character:

static char string_total_flags[] = "0\0\0";

PhatHub avatar Sep 15 '20 16:09 PhatHub

There's a hint that the pending pull request resolved this?

PhatHub avatar Sep 15 '20 16:09 PhatHub

Let's leave this memcpy issue in the code. It's not supposed to be there but maybe someone will have fun with it.

hackgnar avatar Jun 28 '23 02:06 hackgnar