From: Olaf Hering Date: Tue, 16 Jan 2018 09:24:37 +0000 (+0100) Subject: Fix parsing of features in detect_vm_xen_dom0 (#7890) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=26dc3c373d72dcaa70e533d5d0ca626a02bf8785;p=elogind.git 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)") --- diff --git a/src/basic/virt.c b/src/basic/virt.c index 21e11b698..4c3791381 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -223,8 +223,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.",