app_voicemail: Prevent crash when saving message with realtime voicemail

ast_store_realtime() is not NULL tolerant, so we need to initialize
the field values we pass to it to the empty string to avoid a crash.

ASTERISK-23739 #close
Reported by: Stas Kobzar

Change-Id: I756c5dd0299c77f4274368f7c99eb0464367466c
17.2
Sean Bright 5 years ago
parent 8cad8db7d3
commit d1cd27ba1f

@ -4718,11 +4718,15 @@ static int copy(char *infile, char *outfile)
static void copy_plain_file(char *frompath, char *topath)
{
char frompath2[PATH_MAX], topath2[PATH_MAX];
struct ast_variable *tmp,*var = NULL;
const char *origmailbox = NULL, *context = NULL, *macrocontext = NULL, *exten = NULL, *priority = NULL, *callerchan = NULL, *callerid = NULL, *origdate = NULL, *origtime = NULL, *category = NULL, *duration = NULL;
struct ast_variable *tmp, *var = NULL;
const char *origmailbox = "", *context = "", *macrocontext = "", *exten = "";
const char *priority = "", *callerchan = "", *callerid = "", *origdate = "";
const char *origtime = "", *category = "", *duration = "";
ast_filecopy(frompath, topath, NULL);
snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath);
snprintf(topath2, sizeof(topath2), "%s.txt", topath);
if (ast_check_realtime("voicemail_data")) {
var = ast_load_realtime("voicemail_data", "filename", frompath, SENTINEL);
/* This cycle converts ast_variable linked list, to va_list list of arguments, may be there is a better way to do it? */

Loading…
Cancel
Save