[Asterisk-code-review] pjsip/cli commands: pjsip show channelstats shows wrong codec (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Thu Mar 9 10:32:47 CST 2017


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/5120 )

Change subject: pjsip/cli_commands: pjsip show channelstats shows wrong codec
......................................................................


Patch Set 10: Code-Review-1

(3 comments)

The patch is getting there.

https://gerrit.asterisk.org/#/c/5120/10/channels/pjsip/cli_commands.c
File channels/pjsip/cli_commands.c:

Line 352: 	char *codecinuse = alloca(6);
The column size is 6 but you need to also add one for the string null terminator.

It is safer to declare it this way:
char codec_in_use[7];

As an array the sizeof(codec_in_use) below will return the correct size.


Line 362: 	if (channel) {
You need to initialize codecinuse to an empty string in case it isn't set to anything else.

codec_in_use[0] = '\0';
if (channel) {
}


Line 365: 			ast_copy_string(codecinuse, ast_format_get_name(ast_channel_rawreadformat(channel)), sizeof(codecinuse));
In this case sizeof(codecinuse) returns the size of a pointer and not the buffer size.  You have to explicitly pass a 7.

Either that or declare codecinuse as a char array:
char codec_in_use[7];


-- 
To view, visit https://gerrit.asterisk.org/5120
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3889ef6a8f6738fc312fab42db5efacd6e452b01
Gerrit-PatchSet: 10
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Daniel Journo <dan at keshercommunications.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Daniel Journo <dan at keshercommunications.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list