Skip to content

Commit

Permalink
fixed possible buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Oct 25, 2023
1 parent 43a89d2 commit 68c86b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libYARP_os/src/yarp/os/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ SystemInfo::LoadInfo SystemInfo::getLoadInfo()
FILE* procload = fopen("/proc/loadavg", "r");
if (procload != nullptr) {
char buff[128];
int ret = fscanf(procload, "%lf %lf %lf %s", &(load.cpuLoad1), &(load.cpuLoad5), &(load.cpuLoad15), buff);
int ret = fscanf(procload, "%lf %lf %lf %127s", &(load.cpuLoad1), &(load.cpuLoad5), &(load.cpuLoad15), buff);
if (ret > 0) {
char* tail = strchr(buff, '/');
if ((tail != nullptr) && (tail != buff)) {
Expand Down

0 comments on commit 68c86b5

Please sign in to comment.