mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:47:34 +00:00
LibC: Fix invalid 1-byte read I introduced in dirent.
When attempting to fix the dirent code I also changed this to use strlcpy instead of the custom string copy loop that was there before. Looking over strlcpy it looked like it should work when using a non null terminated string, I obviously misinterpreted the implementation as it will read till it finds a null terminator. Manually null terminate the string to address this. Gunnar found this after he fixed UserspaceEmulator. I reproduced it locally using his branch, and also found the memory leak I had in the unit test for the scandir that I added, so lets fix that as well. Reported-by: Gunnar Beutner <gbeutner@serenityos.org>
This commit is contained in:
parent
3a5f9b2f7e
commit
0726d39cb1
2 changed files with 7 additions and 3 deletions
|
@ -19,7 +19,6 @@ TEST_CASE(scandir_basic_scenario)
|
|||
for (auto i = 0; i < entries; i++) {
|
||||
if (strcmp(namelist[i]->d_name, "passwd") == 0) {
|
||||
found_passwd = true;
|
||||
break;
|
||||
}
|
||||
free(namelist[i]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue