Skip to content

Commit 3c40b2e

Browse files
committed
Fix null termination of network module detection
1 parent aef29ac commit 3c40b2e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/boot/FPPINIT.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,8 @@ static void detectNetworkModules() {
937937
std::string modName = "/sys/class/net/" + filename + "/device/driver/module";
938938
if (FileExists(modName)) {
939939
char buf[256];
940-
readlink(modName.c_str(), buf, sizeof(buf));
940+
size_t l = readlink(modName.c_str(), buf, sizeof(buf));
941+
buf[l] = 0;
941942
std::string mod = buf;
942943
mod = mod.substr(mod.rfind("/") + 1);
943944
content += mod;
@@ -1430,6 +1431,8 @@ int main(int argc, char* argv[]) {
14301431
}
14311432
}
14321433
}
1434+
} else if (action == "detectNetworkModules") {
1435+
detectNetworkModules();
14331436
}
14341437
printf("------------------------------\n");
14351438
return 0;

0 commit comments

Comments
 (0)