NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/44390: ftpd/ftpcmd.y inet6 case has out of range subscripts



The following reply was made to PR bin/44390; it has been noted by GNATS.

From: Paul Koning <paul_koning%dell.com@localhost>
To: <gnats-bugs%NetBSD.org@localhost>
Cc: <gnats-admin%netbsd.org@localhost>,
 <netbsd-bugs%netbsd.org@localhost>
Subject: Re: bin/44390: ftpd/ftpcmd.y inet6 case has out of range subscripts
Date: Fri, 14 Jan 2011 15:53:16 -0500

 The attached patch cures the compiler complaint.  It isn't entirely =
 clear to me why this helps, but it seems like a useful change anyway =
 because it eliminates a cast.
 
        paul
 
 Index: ftpcmd.y
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 --- ftpcmd.y   (revision 151799)
 +++ ftpcmd.y   (working copy)
 @@ -966,18 +966,31 @@
                NUMBER
                {
  #ifdef INET6
 -                      char *a, *p;
 -
 +                      char *p;
 +                      struct in6_addr *a;
 +           =20
                        memset(&data_dest, 0, sizeof(data_dest));
                        data_dest.su_len =3D sizeof(struct =
 sockaddr_in6);
                        data_dest.su_family =3D AF_INET6;
                        p =3D (char *)&data_dest.su_port;
                        p[0] =3D $39.i; p[1] =3D $41.i;
 -                      a =3D (char =
 *)&data_dest.si_su.su_sin6.sin6_addr;
 -                      a[0] =3D $5.i; a[1] =3D $7.i; a[2] =3D $9.i; =
 a[3] =3D $11.i;
 -                      a[4] =3D $13.i; a[5] =3D $15.i; a[6] =3D $17.i; =
 a[7] =3D $19.i;
 -                      a[8] =3D $21.i; a[9] =3D $23.i; a[10] =3D $25.i; =
 a[11] =3D $27.i;
 -                      a[12] =3D $29.i; a[13] =3D $31.i; a[14] =3D =
 $33.i; a[15] =3D $35.i;
 +                      a =3D &data_dest.si_su.su_sin6.sin6_addr;
 +                      a.s6_addr[0] =3D $5.i;
 +                      a.s6_addr[1] =3D $7.i;=20
 +                      a.s6_addr[2] =3D $9.i;
 +                      a.s6_addr[3] =3D $11.i;
 +                      a.s6_addr[4] =3D $13.i;
 +                      a.s6_addr[5] =3D $15.i;
 +                      a.s6_addr[6] =3D $17.i;
 +                      a.s6_addr[7] =3D $19.i;
 +                      a.s6_addr[8] =3D $21.i;
 +                      a.s6_addr[9] =3D $23.i;
 +                      a.s6_addr[10] =3D $25.i;=20
 +                      a.s6_addr[11] =3D $27.i;
 +                      a.s6_addr[12] =3D $29.i;
 +                      a.s6_addr[13] =3D $31.i;
 +                      a.s6_addr[14] =3D $33.i;
 +                      a.s6_addr[15] =3D $35.i;
                        if (his_addr.su_family =3D=3D AF_INET6) {
                                /* XXX: more sanity checks! */
                                data_dest.su_scope_id =3D =
 his_addr.su_scope_id;
 


Home | Main Index | Thread Index | Old Index