config: bug: Fix SEGV in ast_category_insert when matching category isn't found

If you call ast_category_insert with a match category that doesn't exist, the
list traverse runs out of 'next' categories and you get a SEGV.  This patch
adds check for the end-of-list condition and changes the signature to return
an int for success/failure indication instead of a void.

The only consumer of this function is manager and it was also changed to use
the return value.

Tested by: George Joseph
Review: https://reviewboard.asterisk.org/r/3993/
........

Merged revisions 423276 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 423277 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 423278 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
George Joseph
2014-09-18 14:45:04 +00:00
parent c48b609fb3
commit 0a2e6a1c7e
3 changed files with 19 additions and 8 deletions

View File

@@ -3313,7 +3313,11 @@ static enum error_type handle_updates(struct mansession *s, const struct message
if (ast_strlen_zero(match)) {
ast_category_append(cfg, category);
} else {
ast_category_insert(cfg, category, match);
if (ast_category_insert(cfg, category, match)) {
result = FAILURE_NEWCAT;
ast_category_destroy(category);
break;
}
}
} else if (!strcasecmp(action, "renamecat")) {
if (ast_strlen_zero(value)) {