]> xenbits.xensource.com Git - libvirt.git/commit
log_cleaner: Detect rotated filenames properly
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 29 May 2024 07:24:44 +0000 (09:24 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 31 May 2024 06:34:29 +0000 (08:34 +0200)
commita57195e79efc9208fa4bc55439b9b798d2e3de50
tree9f354eaabd610468d2d2bf6e74ec2aa603418242
parent6f293f1fadc08660ba470d2cd3a91fde58cef617
log_cleaner: Detect rotated filenames properly

When removing rotated log files, their name is matched against a
regex (@log_regex) and if they contain '.N' suffix the 'N' is
then parsed into an integer. Well, due to a bug in
virLogCleanerParseFilename() this is not how the code works. If
the suffix isn't found then g_match_info_fetch() returns an empty
string instead of NULL which then makes str2int parsing fail.
Just check for this case before parsing the string.

Based on the original patch sent by David.

Reported-by: David Negreira <david.negreira@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/logging/log_cleaner.c