app_voicemail: Prevent crash when saving message with realtime voicemail
authorSean Bright <sean.bright@gmail.com>
Wed, 15 Jan 2020 20:29:00 +0000 (15:29 -0500)
committerSean Bright <sean.bright@gmail.com>
Wed, 15 Jan 2020 21:52:25 +0000 (15:52 -0600)
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

apps/app_voicemail.c

index cf944fd..1ab9d01 100644 (file)
@@ -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? */