mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
core: Cleanup ast_get_hint() usage.
* manager.c:manager_state_cb() Fix potential use of uninitialized hint[] if a hint does not exist for the requested extension. Ran into this when developing a testsuite test. The AMI event ExtensionStatus came out with the hint header value containing garbage. The AMI event PresenceStatus also had the same issue. * manager.c:action_extensionstate() no need to completely initialize the hint[]. Only initialize the first element. * pbx.c:ast_add_hint() Remove unnecessary assignment. * chan_sip.c: Eliminate an unneeded hint[] local variable. We only care about the return value of ast_get_hint() there. Change-Id: Ia9a8786f01f93f1f917200f0a50bead0319af97b
This commit is contained in:
@@ -5680,8 +5680,9 @@ static int action_extensionstate(struct mansession *s, const struct message *m)
|
||||
{
|
||||
const char *exten = astman_get_header(m, "Exten");
|
||||
const char *context = astman_get_header(m, "Context");
|
||||
char hint[256] = "";
|
||||
char hint[256];
|
||||
int status;
|
||||
|
||||
if (ast_strlen_zero(exten)) {
|
||||
astman_send_error(s, m, "Extension not specified");
|
||||
return 0;
|
||||
@@ -5690,16 +5691,18 @@ static int action_extensionstate(struct mansession *s, const struct message *m)
|
||||
context = "default";
|
||||
}
|
||||
status = ast_extension_state(NULL, context, exten);
|
||||
ast_get_hint(hint, sizeof(hint) - 1, NULL, 0, NULL, context, exten);
|
||||
hint[0] = '\0';
|
||||
ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, context, exten);
|
||||
astman_start_ack(s, m);
|
||||
astman_append(s, "Message: Extension Status\r\n"
|
||||
"Exten: %s\r\n"
|
||||
"Context: %s\r\n"
|
||||
"Hint: %s\r\n"
|
||||
"Status: %d\r\n"
|
||||
"StatusText: %s\r\n\r\n",
|
||||
exten, context, hint, status,
|
||||
ast_extension_state2str(status));
|
||||
astman_append(s, "Message: Extension Status\r\n"
|
||||
"Exten: %s\r\n"
|
||||
"Context: %s\r\n"
|
||||
"Hint: %s\r\n"
|
||||
"Status: %d\r\n"
|
||||
"StatusText: %s\r\n"
|
||||
"\r\n",
|
||||
exten, context, hint, status,
|
||||
ast_extension_state2str(status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6973,6 +6976,7 @@ static int manager_state_cb(const char *context, const char *exten, struct ast_s
|
||||
/* Notify managers of change */
|
||||
char hint[512];
|
||||
|
||||
hint[0] = '\0';
|
||||
ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, context, exten);
|
||||
|
||||
switch(info->reason) {
|
||||
|
Reference in New Issue
Block a user