d0k3 / GodMode9

GodMode9 Explorer - A full access file browser for the Nintendo 3DS console :godmode:
GNU General Public License v3.0
2.09k stars 190 forks source link

use sizeof with snprintf when target is an array #778

Closed gemarcano closed 2 years ago

gemarcano commented 2 years ago

I tried to only modify snprintf calls that worked on buffers with known sizes, as sometimes they're used with buffers passed in as parameters (with expected sizes, but can't be determined via sizeof). Hopefully none of these snuck though.

I haven't tested this yet on my 3DS. I'll update the state to not a draft once I can confirm I can boot this.

gemarcano commented 2 years ago

Just checked, G9 boots fine on my 3DS. Confirmed that is a build I made as of today and not an old copy.

Wolfvak commented 2 years ago

Nice bug fix and thanks for the rest! For the future, perhaps just replacing all calls that use a fixed-size array as the target should use a macro (say, #define format_buf(b, s, ...) snprintf(b, sizeof(b), s, __VA_ARGS__))) but that might be even more trouble than it's worth.