From a41505f66b47892e9d5abcc2b6efa8cce0c994da Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 23 Feb 2015 16:38:17 -0600 Subject: [PATCH] FS-7313 #resolve any further issues in this code it will just be removed --- .../applications/mod_voicemail/mod_voicemail.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 678f00f366..d24fecc6a4 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -5953,6 +5953,7 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function) msg_get_callback_t cbt = { 0 }; char *sql; switch_memory_pool_t *pool; + switch_xml_t x_user = NULL; switch_core_new_memory_pool(&pool); @@ -5972,11 +5973,18 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function) if (argv[4]) email = argv[4]; + if (!profile_name || !domain || !id || !uuid || !email) { stream->write_function(stream, "-ERR Missing Arguments\n"); goto done; } + if (switch_xml_locate_user_merged("id", id, domain, NULL, &x_user, NULL) != SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "-ERR Can't locate user.\n"); + switch_xml_free(x_user); + goto done; + } + if (!(profile = get_profile(profile_name))) { stream->write_function(stream, "-ERR Profile not found\n"); goto done; @@ -5998,6 +6006,7 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function) switch_core_time_duration_t duration; char duration_str[80]; char *formatted_cid_num = NULL; + char *msg_uuid = NULL; sql = switch_mprintf("select created_epoch, read_epoch, username, domain, uuid, cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags, forwarded_by from voicemail_msgs WHERE username = '%q' AND domain = '%q' AND uuid = '%q' ORDER BY read_flags, created_epoch", id, domain, uuid); memset(&cbt, 0, sizeof(cbt)); @@ -6005,6 +6014,13 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function) vm_execute_sql_callback(profile, profile->mutex, sql, message_get_callback, &cbt); switch_safe_free(sql); + msg_uuid = switch_event_get_header(cbt.my_params, "VM-Message-UUID"); + + if (!msg_uuid) { + profile_rwunlock(profile); + stream->write_function(stream, "-ERR Invalid Message UUID\n"); + goto done; + } if (!strcasecmp(switch_event_get_header(cbt.my_params, "VM-Message-Read-Flags"), URGENT_FLAG_STRING)) { priority = 1; }