Skip to content
Snippets Groups Projects
Commit a57195e7 authored by Michal Privoznik's avatar Michal Privoznik
Browse files

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: default avatarDavid Negreira <david.negreira@canonical.com>
Signed-off-by: default avatarMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: default avatarJiri Denemark <jdenemar@redhat.com>
parent 6f293f1f
No related branches found
No related tags found
No related merge requests found
...@@ -82,10 +82,8 @@ virLogCleanerParseFilename(const char *path, ...@@ -82,10 +82,8 @@ virLogCleanerParseFilename(const char *path,
*rotated_index = 0; *rotated_index = 0;
rotated_index_str = g_match_info_fetch(matchInfo, 3); rotated_index_str = g_match_info_fetch(matchInfo, 3);
if (!rotated_index_str) if (rotated_index_str && STRNEQ(rotated_index_str, "") &&
return chain_prefix; virStrToLong_i(rotated_index_str, NULL, 10, rotated_index) < 0) {
if (virStrToLong_i(rotated_index_str, NULL, 10, rotated_index) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse rotated index from '%1$s'"), _("Failed to parse rotated index from '%1$s'"),
rotated_index_str); rotated_index_str);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment