On Tue, Jul 23, 2024 at 13:54:33 +0200, Michal Privoznik wrote: > 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@xxxxxxxxxx> > --- > > v2 of: > > https://lists.libvirt.org/archives/list/devel@xxxxxxxxxxxxxxxxx/thread/LK74PN7JIDVKY5MZC4664RZTMOG7F5AR/ > > diff to v2: > - Keep trimming of the optional newline > > tools/virt-host-validate-common.c | 18 +++++++----------- > 1 file changed, 7 insertions(+), 11 deletions(-) Reviewed-by: Jiri Denemark <jdenemar@xxxxxxxxxx>