Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where bad registration info leads to NULL dereference crash #355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions res/res_rpt_http_registrations.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ static int http_register(struct http_registry *reg)
port = ast_json_integer_get(ast_json_object_get(json, "port"));
refresh = ast_json_integer_get(ast_json_object_get(json, "refresh"));
data = ast_json_dump_string(ast_json_object_get(json, "data"));
ast_debug(2, "Response: ipaddr=%s, port=%d, refresh=%d, data=%s\n", ipaddr, port, refresh, data);
if (strstr(data, "successfully registered")) {
ast_debug(2, "Response: ipaddr=%s, port=%d, refresh=%d, data=%s\n",
ipaddr, port, refresh, data);
if (data && strstr(data, "successfully registered")) {
ast_copy_string(reg->perceived, ipaddr, sizeof(reg->perceived));
reg->perceived_port = port;
reg->refresh = refresh;
Expand Down Expand Up @@ -336,7 +337,12 @@ static char *handle_show_registrations(struct ast_cli_entry *e, int cmd, struct
ast_copy_string(perceived, "<Unregistered>", sizeof(perceived));
}
snprintf(host, sizeof(host), "%s", ast_sockaddr_stringify(&reg->addr));
ast_cli(a->fd, FORMAT, host, reg->username, reg->perceived_port ? perceived : "<Unregistered>", reg->refresh, reg->registered ? "Registered" : "Not Registered");
ast_cli(a->fd, FORMAT,
host,
reg->username,
reg->perceived_port ? perceived : "<Unregistered>",
reg->refresh,
reg->registered ? "Registered" : "Not Registered");
counter++;
}
AST_RWLIST_UNLOCK(&registrations);
Expand Down
Loading