assigned-uniqueids: Miscellaneous cleanup and fixes.

* Fix memory leak in ast_unreal_new_channels().  Made it generate the ;2
uniqueid on a stack variable instead of mallocing it.

* Made send error response to ARI and AMI requests instead of just logging
excessive uniqueid length and allowing truncation.  action_originate() and
ari_channels_handle_originate_with_id().

* Fixed minor truncating uniqueid hole when generating the ;2 uniqueid
string length.  Created public and internal lengths of uniqueid.  The
internal length can handle a max public uniqueid plus an appended ;2.

* free() and ast_free() are NULL tolerant so they don't need a NULL test
before calling.

* Made use better struct initialization format instead of the position
dependent initialization format.  Also anything not explicitly initialized
in the struct is initialized to zero by the compiler.

* Made ast_channel_internal_set_fake_ids() use the safer
ast_copy_string() instead of strncpy().

Review: https://reviewboard.asterisk.org/r/3371/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@410949 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2014-03-20 16:27:49 +00:00
parent c2dd050e1a
commit ce6048c07f
8 changed files with 77 additions and 45 deletions

View File

@@ -907,7 +907,10 @@ struct ast_channel *ast_unreal_new_channels(struct ast_unreal_pvt *p,
/* if id1 given but not id2, use default of id1;2 */
if (id1.uniqueid && ast_strlen_zero(id2.uniqueid)) {
char *uniqueid2;
ast_asprintf(&uniqueid2, "%s;2", id1.uniqueid);
uniqueid2 = ast_alloca(strlen(id1.uniqueid) + 2);
strcpy(uniqueid2, id1.uniqueid);/* Safe */
strcat(uniqueid2, ";2");/* Safe */
id2.uniqueid = uniqueid2;
}