]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virt-host-validate: Allow longer list of CPU flags
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 23 Jul 2024 08:31:27 +0000 (10:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 23 Jul 2024 11:58:53 +0000 (13:58 +0200)
commite5232f6fd691668decd5be1b3a76cdbd3666d032
treebfca0a684a49816d7c6b661108653c20f4e84db3
parent8f3b46e30bbc92466a4291c2210374c3b79b752d
virt-host-validate: Allow longer list of CPU flags

On various occasions, virt-host-validate parses /proc/cpuinfo to
learn about CPU flags (see virHostValidateGetCPUFlags()). It does
so, by reading the file line by line until the line with CPU
flags is reached. Then the line is split into individual flags
(using space as a delimiter) and the list of flags is then
iterated over.

This works, except for cases when the line with CPU flags is too
long. Problem is - the line is capped at 1024 bytes and on newer
CPUs (and newer kernels), the line can be significantly longer.
I've seen a line that's ~1200 characters long (with 164 flags
reported).

Switch to unbounded read from the file (getline()).

Resolves: https://issues.redhat.com/browse/RHEL-39969
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
tools/virt-host-validate-common.c