mirror of
https://github.com/systemd/systemd
synced 2024-07-21 02:05:05 +00:00
cgtop: fix sscanf return code checks
sscanf can return EOF on error, so check that we get a result instead. CodeQL#2386 and CodeQL#2387
This commit is contained in:
parent
201f6241ae
commit
204d52c4b7
|
@ -310,9 +310,9 @@ static int process(
|
|||
|
||||
if (all_unified) {
|
||||
while (!isempty(l)) {
|
||||
if (sscanf(l, "rbytes=%" SCNu64, &k))
|
||||
if (sscanf(l, "rbytes=%" SCNu64, &k) == 1)
|
||||
rd += k;
|
||||
else if (sscanf(l, "wbytes=%" SCNu64, &k))
|
||||
else if (sscanf(l, "wbytes=%" SCNu64, &k) == 1)
|
||||
wr += k;
|
||||
|
||||
l += strcspn(l, WHITESPACE);
|
||||
|
|
Loading…
Reference in a new issue