diff options
author | Karel Zak | 2018-09-04 13:12:34 +0200 |
---|---|---|
committer | Karel Zak | 2018-09-04 13:12:34 +0200 |
commit | d0b75b03bca36ed8a548655bba74297996cd69a6 (patch) | |
tree | 24a253bb4b8a199b383be84b8ae77d4bb60a9a34 /sys-utils/lscpu.c | |
parent | build-sys: default to /lib64 for ${exec_prefix}/lib64 (diff) | |
download | kernel-qcow2-util-linux-d0b75b03bca36ed8a548655bba74297996cd69a6.tar.gz kernel-qcow2-util-linux-d0b75b03bca36ed8a548655bba74297996cd69a6.tar.xz kernel-qcow2-util-linux-d0b75b03bca36ed8a548655bba74297996cd69a6.zip |
lscpu: make xasprintf call more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 122acca1a..57f097dae 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -837,7 +837,7 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod) desc->hypervisor = "PR/SM"; desc->virtype = VIRT_FULL; while (fgets(buf, sizeof(buf), fd) != NULL) { - char *str; + char *str, *p; if (!strstr(buf, "Control Program:")) continue; @@ -845,10 +845,10 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod) desc->hyper = HYPER_IBM; else desc->hyper = HYPER_KVM; - str = strchr(buf, ':'); - if (!str) + p = strchr(buf, ':'); + if (!p) continue; - xasprintf(&str, "%s", str + 1); + xasprintf(&str, "%s", p + 1); /* remove leading, trailing and repeating whitespace */ while (*str == ' ') |