summaryrefslogtreecommitdiffstats
path: root/src/basic/virt.c
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2018-01-16 10:24:37 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-01-16 10:24:37 +0100
commit13e0f9fe8334859ee86f4ff725374d1d83f5baf7 (patch)
treebe5a88ba148b2db0fa943455a1742053f5553cca /src/basic/virt.c
parentMerge pull request #7540 from fbuihuu/systemd-delta-tweaks (diff)
downloadsystemd-13e0f9fe8334859ee86f4ff725374d1d83f5baf7.tar.xz
systemd-13e0f9fe8334859ee86f4ff725374d1d83f5baf7.zip
Fix parsing of features in detect_vm_xen_dom0 (#7890)
Use sscanf instead of the built-in safe_atolu because the scanned string lacks the leading "0x", it is generated with snprintf(b, "%08x", val). As a result strtoull handles it as octal, and parsing fails. The initial submission already used sscanf, then parsing was replaced by safe_atolu without retesting the updated PR. Fixes 575e6588d ("virt: use XENFEAT_dom0 to detect the hardware domain (#6442, #6662) (#7581)")
Diffstat (limited to '')
-rw-r--r--src/basic/virt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c
index fe582833a7..9b6abf9f19 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -222,8 +222,8 @@ static int detect_vm_xen_dom0(void) {
if (r == 0) {
unsigned long features;
- r = safe_atolu(domcap, &features);
- if (r == 0) {
+ r = sscanf(domcap, "%lx", &features);
+ if (r == 1) {
r = !!(features & (1U << XENFEAT_dom0));
log_debug("Virtualization XEN, found %s with value %08lx, "
"XENFEAT_dom0 (indicating the 'hardware domain') is%s set.",