diff options
author | Luca Boccassi <bluca@debian.org> | 2024-01-19 16:12:49 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2024-01-19 19:00:23 +0100 |
commit | 204d52c4b79eb19d2919cb5214e999c58a6679c6 (patch) | |
tree | e87ec49df26d0a9cc9a3d8e39cb88576f2622c75 /src | |
parent | Merge pull request #31022 from aafeijoo-suse/bash-completion-cryptenroll-2 (diff) | |
download | systemd-204d52c4b79eb19d2919cb5214e999c58a6679c6.tar.xz systemd-204d52c4b79eb19d2919cb5214e999c58a6679c6.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/cgtop/cgtop.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index e34da7cf72..ca51455440 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -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); |