[Asterisk-code-review] app voicemail: always copy dynamic struct to avoid race cond... (asterisk[13])
Andrew Nagy
asteriskteam at digium.com
Thu Mar 17 14:32:44 CDT 2016
Andrew Nagy has uploaded a new change for review.
https://gerrit.asterisk.org/2433
Change subject: app_voicemail: always copy dynamic struct to avoid race condition
......................................................................
app_voicemail: always copy dynamic struct to avoid race condition
ASTERISK-24463 Voicemail email addresses can be corrupt or voicemail
emails can end up being sent to the wrong email address if asterisk is
reading voicemail.conf during a reload and processing an email at the
same time. This patch always copies the struct that would otherwise only
be copied once.
Change-Id: I3a0643813116da84e2617291903d0d489b7425fb
---
M apps/app_voicemail.c
1 file changed, 10 insertions(+), 15 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/2433/1
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 0755c44..b338500 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1725,11 +1725,9 @@
/* Make a copy, so that on a reload, we have no race */
if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) {
*vmu = *cur;
- if (!ivm) {
- vmu->email = ast_strdup(cur->email);
- vmu->emailbody = ast_strdup(cur->emailbody);
- vmu->emailsubject = ast_strdup(cur->emailsubject);
- }
+ vmu->email = ast_strdup(cur->email);
+ vmu->emailbody = ast_strdup(cur->emailbody);
+ vmu->emailsubject = ast_strdup(cur->emailsubject);
ast_set2_flag(vmu, !ivm, VM_ALLOCED);
AST_LIST_NEXT(vmu, list) = NULL;
}
@@ -2007,17 +2005,14 @@
static void free_user(struct ast_vm_user *vmu)
{
+ ast_free(vmu->email);
+ vmu->email = NULL;
+ ast_free(vmu->emailbody);
+ vmu->emailbody = NULL;
+ ast_free(vmu->emailsubject);
+ vmu->emailsubject = NULL;
+
if (ast_test_flag(vmu, VM_ALLOCED)) {
-
- ast_free(vmu->email);
- vmu->email = NULL;
-
- ast_free(vmu->emailbody);
- vmu->emailbody = NULL;
-
- ast_free(vmu->emailsubject);
- vmu->emailsubject = NULL;
-
ast_free(vmu);
}
}
--
To view, visit https://gerrit.asterisk.org/2433
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a0643813116da84e2617291903d0d489b7425fb
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Andrew Nagy <andrew.nagy at the159.com>
More information about the asterisk-code-review
mailing list