From b0cb4ef3e88c0a89a0f9d63018a530f6cd2556c7 Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Mon, 16 Mar 2020 12:35:01 +0100 Subject: [PATCH] breg: fix crash when manually setting regexwhere When manually setting the regular expression during restore like with: OK to run? (yes/mod/no): mod ->11: File Relocation ->4: Enter a regexp ->Please enter a valid regexp (!from!to!): !what!with! ->6: Use this ? The director crashed. This happens because the member regex_t preg of the class BareosRegex was not zero initialized correctly. This caused the freeing of random memory in void regfree(regex_t* preg). Now all members of class BareosRegex are zero initialized and the problem is fixed. This problem also causes the filedaemon to crash when regexwhere is specified in the restore job configuration. On the second restore run the filedaemon crashes. Fixes# 1211: bareos director and bareos fd crash when regexwhere is specified --- core/src/lib/breg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/lib/breg.h b/core/src/lib/breg.h index c60da1f426e..6f874056053 100644 --- a/core/src/lib/breg.h +++ b/core/src/lib/breg.h @@ -2,7 +2,7 @@ BAREOSĀ® - Backup Archiving REcovery Open Sourced Copyright (C) 2006-2006 Free Software Foundation Europe e.V. - Copyright (C) 2016-2016 Bareos GmbH & Co. KG + Copyright (C) 2016-2020 Bareos GmbH & Co. KG This program is Free Software; you can redistribute it and/or modify it under the terms of version three of the GNU Affero General Public @@ -68,7 +68,7 @@ class BareosRegex { /* private */ POOLMEM* expr = nullptr; /**< search epression */ POOLMEM* subst = nullptr; /**< substitution */ - regex_t preg; /**< regex_t result of regcomp() */ + regex_t preg = {}; /**< regex_t result of regcomp() */ regmatch_t regs[BREG_NREGS]; /**< contains match */ char* eor = nullptr; /**< end of regexp in expr */