Ethereal-dev: Re: [ethereal-dev] v-0.8.6: compilation of packet-rsvp.c

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

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Fri, 7 Apr 2000 12:10:25 -0700
> I had two little problems in compiling ethereal-0.8.6 on
> HP-UX 10.20 with the native HP C-Compiler.
> The compilation stopped due to the zero array length in
> 
> packet-rsvp.c: line 557   guint32 labels[0];
> and
> packet-rsvp.c: line 572   guint8 name[0];

Yes, that's an extension that not all compilers support, and therefore
an extension that we should avoid using in Ethereal.

I've attached a patch that changes the RSVP dissector not to use them;
I'll check that in.
Index: packet-rsvp.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-rsvp.c,v
retrieving revision 1.18
diff -c -r1.18 packet-rsvp.c
*** packet-rsvp.c	2000/03/14 06:03:24	1.18
--- packet-rsvp.c	2000/04/07 19:08:56
***************
*** 554,561 ****
  
  typedef struct {
      rsvp_object base;
!     guint32 labels[0];
! } label;
  
  typedef struct {
      rsvp_object base;
--- 554,560 ----
  
  typedef struct {
      rsvp_object base;
! } label;		/* array of 32-bit labels follows */
  
  typedef struct {
      rsvp_object base;
***************
*** 569,576 ****
      guint8 hold_prio;
      guint8 flags;
      guint8 name_len;
!     guint8 name[0];
! } session_attribute;
  
  static const value_string proto_vals[] = { {IP_PROTO_ICMP, "ICMP"},
                                             {IP_PROTO_IGMP, "IGMP"},
--- 568,574 ----
      guint8 hold_prio;
      guint8 flags;
      guint8 name_len;
! } session_attribute;	/* name follows, as string */
  
  static const value_string proto_vals[] = { {IP_PROTO_ICMP, "ICMP"},
                                             {IP_PROTO_IGMP, "IGMP"},
***************
*** 1750,1756 ****
  		    proto_tree_add_text(rsvp_object_tree, offset2+3, 1,
  					"Name length: %d", s_attr->name_len);
  		    memset(s_name, 0, 64);
! 		    strncpy(s_name, s_attr->name, 60); 
  		    if (s_attr->name_len>60) sprintf(&(s_name[60]), "...");
  		    proto_tree_add_text(rsvp_object_tree, offset2+4, s_attr->name_len,
  					"Name: %s", s_name);
--- 1748,1754 ----
  		    proto_tree_add_text(rsvp_object_tree, offset2+3, 1,
  					"Name length: %d", s_attr->name_len);
  		    memset(s_name, 0, 64);
! 		    strncpy(s_name, &pd[offset2+4], 60);
  		    if (s_attr->name_len>60) sprintf(&(s_name[60]), "...");
  		    proto_tree_add_text(rsvp_object_tree, offset2+4, s_attr->name_len,
  					"Name: %s", s_name);