Ethereal-dev: Re: [Ethereal-dev] bad buffer bound in packet-cpha.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Tue, 15 Apr 2003 15:08:46 -0700
On Tue, Apr 15, 2003 at 08:28:46PM +0100, Anil Madhavapeddy wrote:
> Noticed this in Ethereal-0.9.11

...and then, while looking at the fix, I noticed that there wasn't any
need to use "snprintf()" at all:

*** packet-cpha.c	31 Jan 2003 03:17:45 -0000	1.5
--- packet-cpha.c	15 Apr 2003 22:07:21 -0000	1.6
***************
*** 199,205 ****
    proto_item *		nti;
    proto_tree *		cpha_tree = NULL;
    proto_tree *		ntree = NULL;
-   static char		info[30];
    guint16		opcode;
  
    /*
--- 199,204 ----
***************
*** 237,245 ****
    hdr.filler = g_ntohs(hdr.filler);
    opcode  = g_ntohs(hdr.opcode);
  
-   snprintf(info,50,"CPHAv%d: %s",g_ntohs(hdr.ha_protocol_ver), opcode2str_short(opcode));
    if (check_col(pinfo->cinfo, COL_INFO))
!     col_add_str(pinfo->cinfo, COL_INFO,info);
  
    if (tree) {
      ti = proto_tree_add_item(tree, proto_cphap, tvb, offset, -1, FALSE);
--- 236,244 ----
    hdr.filler = g_ntohs(hdr.filler);
    opcode  = g_ntohs(hdr.opcode);
  
    if (check_col(pinfo->cinfo, COL_INFO))
!     col_add_fstr(pinfo->cinfo, COL_INFO, "CPHAv%d: %s",
!         g_ntohs(hdr.ha_protocol_ver), opcode2str_short(opcode));
  
    if (tree) {
      ti = proto_tree_add_item(tree, proto_cphap, tvb, offset, -1, FALSE);

and checked in that change instead.