mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
ensure buffer is adequately sized for frames with lots of elements (issue #4974)
various minor formatting/cleanup changes git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6386 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -373,7 +373,7 @@ static void dump_ies(unsigned char *iedata, int len)
|
|||||||
|
|
||||||
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen)
|
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen)
|
||||||
{
|
{
|
||||||
char *frames[] = {
|
const char *frames[] = {
|
||||||
"(0?)",
|
"(0?)",
|
||||||
"DTMF ",
|
"DTMF ",
|
||||||
"VOICE ",
|
"VOICE ",
|
||||||
@@ -385,7 +385,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
|||||||
"IMAGE ",
|
"IMAGE ",
|
||||||
"HTML ",
|
"HTML ",
|
||||||
"CNG " };
|
"CNG " };
|
||||||
char *iaxs[] = {
|
const char *iaxs[] = {
|
||||||
"(0?)",
|
"(0?)",
|
||||||
"NEW ",
|
"NEW ",
|
||||||
"PING ",
|
"PING ",
|
||||||
@@ -425,7 +425,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
|||||||
"FWDOWNLD",
|
"FWDOWNLD",
|
||||||
"FWDATA"
|
"FWDATA"
|
||||||
};
|
};
|
||||||
char *cmds[] = {
|
const char *cmds[] = {
|
||||||
"(0?)",
|
"(0?)",
|
||||||
"HANGUP ",
|
"HANGUP ",
|
||||||
"RING ",
|
"RING ",
|
||||||
@@ -438,11 +438,12 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
|||||||
char retries[20];
|
char retries[20];
|
||||||
char class2[20];
|
char class2[20];
|
||||||
char subclass2[20];
|
char subclass2[20];
|
||||||
char *class;
|
const char *class;
|
||||||
char *subclass;
|
const char *subclass;
|
||||||
char *dir;
|
char *dir;
|
||||||
char tmp[256];
|
char tmp[512];
|
||||||
char iabuf[INET_ADDRSTRLEN];
|
char iabuf[INET_ADDRSTRLEN];
|
||||||
|
|
||||||
switch(rx) {
|
switch(rx) {
|
||||||
case 0:
|
case 0:
|
||||||
dir = "Tx";
|
dir = "Tx";
|
||||||
@@ -459,7 +460,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
|||||||
}
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
fh = f->data;
|
fh = f->data;
|
||||||
snprintf(retries, (int)sizeof(retries), "%03d", f->retries);
|
snprintf(retries, sizeof(retries), "%03d", f->retries);
|
||||||
} else {
|
} else {
|
||||||
fh = fhi;
|
fh = fhi;
|
||||||
if (ntohs(fh->dcallno) & IAX_FLAG_RETRANS)
|
if (ntohs(fh->dcallno) & IAX_FLAG_RETRANS)
|
||||||
@@ -472,7 +473,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fh->type >= (int)sizeof(frames)/(int)sizeof(frames[0])) {
|
if (fh->type >= (int)sizeof(frames)/(int)sizeof(frames[0])) {
|
||||||
snprintf(class2, (int)sizeof(class2), "(%d?)", fh->type);
|
snprintf(class2, sizeof(class2), "(%d?)", fh->type);
|
||||||
class = class2;
|
class = class2;
|
||||||
} else {
|
} else {
|
||||||
class = frames[(int)fh->type];
|
class = frames[(int)fh->type];
|
||||||
@@ -482,32 +483,32 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
|||||||
subclass = subclass2;
|
subclass = subclass2;
|
||||||
} else if (fh->type == AST_FRAME_IAX) {
|
} else if (fh->type == AST_FRAME_IAX) {
|
||||||
if (fh->csub >= (int)sizeof(iaxs)/(int)sizeof(iaxs[0])) {
|
if (fh->csub >= (int)sizeof(iaxs)/(int)sizeof(iaxs[0])) {
|
||||||
snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
|
snprintf(subclass2, sizeof(subclass2), "(%d?)", fh->csub);
|
||||||
subclass = subclass2;
|
subclass = subclass2;
|
||||||
} else {
|
} else {
|
||||||
subclass = iaxs[(int)fh->csub];
|
subclass = iaxs[(int)fh->csub];
|
||||||
}
|
}
|
||||||
} else if (fh->type == AST_FRAME_CONTROL) {
|
} else if (fh->type == AST_FRAME_CONTROL) {
|
||||||
if (fh->csub >= (int)sizeof(cmds)/(int)sizeof(cmds[0])) {
|
if (fh->csub >= (int)sizeof(cmds)/(int)sizeof(cmds[0])) {
|
||||||
snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
|
snprintf(subclass2, sizeof(subclass2), "(%d?)", fh->csub);
|
||||||
subclass = subclass2;
|
subclass = subclass2;
|
||||||
} else {
|
} else {
|
||||||
subclass = cmds[(int)fh->csub];
|
subclass = cmds[(int)fh->csub];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(subclass2, (int)sizeof(subclass2), "%d", fh->csub);
|
snprintf(subclass2, sizeof(subclass2), "%d", fh->csub);
|
||||||
subclass = subclass2;
|
subclass = subclass2;
|
||||||
}
|
}
|
||||||
snprintf(tmp, (int)sizeof(tmp),
|
snprintf(tmp, sizeof(tmp),
|
||||||
"%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n",
|
"%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n",
|
||||||
dir,
|
dir,
|
||||||
retries, fh->oseqno, fh->iseqno, class, subclass);
|
retries, fh->oseqno, fh->iseqno, class, subclass);
|
||||||
outputf(tmp);
|
outputf(tmp);
|
||||||
snprintf(tmp, (int)sizeof(tmp),
|
snprintf(tmp, sizeof(tmp),
|
||||||
" Timestamp: %05lums SCall: %5.5d DCall: %5.5d [%s:%d]\n",
|
" Timestamp: %05lums SCall: %5.5d DCall: %5.5d [%s:%d]\n",
|
||||||
(unsigned long)ntohl(fh->ts),
|
(unsigned long)ntohl(fh->ts),
|
||||||
ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS,
|
ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS,
|
||||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
||||||
outputf(tmp);
|
outputf(tmp);
|
||||||
if (fh->type == AST_FRAME_IAX)
|
if (fh->type == AST_FRAME_IAX)
|
||||||
dump_ies(fh->iedata, datalen);
|
dump_ies(fh->iedata, datalen);
|
||||||
|
Reference in New Issue
Block a user