Skip to content

Commit

Permalink
Fix null termination of network module detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Feb 10, 2025
1 parent 633fc58 commit 36af981
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/boot/FPPINIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ static void detectNetworkModules() {
std::string modName = "/sys/class/net/" + filename + "/device/driver/module";
if (FileExists(modName)) {
char buf[256];
readlink(modName.c_str(), buf, sizeof(buf));
size_t l = readlink(modName.c_str(), buf, sizeof(buf));
buf[l] = 0;
std::string mod = buf;
mod = mod.substr(mod.rfind("/") + 1);
content += mod;
Expand Down Expand Up @@ -1435,6 +1436,8 @@ int main(int argc, char* argv[]) {
}
}
}
} else if (action == "detectNetworkModules") {
detectNetworkModules();
}
printf("------------------------------\n");
return 0;
Expand Down

0 comments on commit 36af981

Please sign in to comment.