Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

Fix undefined behavior in `strncpy()` call

Open LocalSpook opened this issue 1 year ago • 0 comments

strncpy()'s pointer parameters are marked restrict, but when file_browser_reload_directory_content() was being called to reload the directory that was currently open:

file_browser_reload_directory_content(browser, browser->directory)

it would try to copy its path buffer to itself, causing undefined behavior. The solution uses memmove(), which can handle overlapping pointers.

Found with Address Sanitizer.

LocalSpook avatar Dec 19 '23 05:12 LocalSpook