diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-10-12 00:34:51 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-10-12 00:34:51 +0000 |
commit | a429816602bb787f63a14d3e912f4123874b13ec (patch) | |
tree | 55b57390599a57c08fb0276d98ade84bb9db847b /tap-protohierstat.c | |
parent | 4dd264cc659cc220e84d3dbfbf799aa542c4669f (diff) |
fix the phs tap so it does not write beyond the end of the string (which sits on the stack)
this fixes the bug that sunil reported to the mailinglist
svn path=/trunk/; revision=16196
Diffstat (limited to 'tap-protohierstat.c')
-rw-r--r-- | tap-protohierstat.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tap-protohierstat.c b/tap-protohierstat.c index fd8238a88c..7b79a70a8b 100644 --- a/tap-protohierstat.c +++ b/tap-protohierstat.c @@ -136,17 +136,23 @@ protohierstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const v static void phs_draw(phs_t *rs, int indentation) { - int i; - char str[80]; + int i, stroff; +#define MAXPHSLINE 80 + char str[MAXPHSLINE]; for(;rs;rs=rs->sibling){ if(rs->protocol==-1){ return; } str[0]=0; + stroff=0; for(i=0;i<indentation;i++){ - strcat(str," "); + if(i>15){ + stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, "..."); + break; + } + stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, " "); } - strcat(str, rs->proto_name); + stroff+=g_snprintf(str+stroff, MAXPHSLINE-stroff, rs->proto_name); printf("%-40s frames:%d bytes:%d\n",str, rs->frames, rs->bytes); phs_draw(rs->child, indentation+1); } |