Date: Sun, 15 Jan 2006 19:29:41 +0100 From: Ulrich Spoerlein <q@galgenberg.net> To: Rong-En Fan <grafan@gmail.com>, current@freebsd.org Subject: [PATCH] Fix off-by-one bug in ifconfig's af_link.c Message-ID: <20060115182941.GA1182@galgenberg.net> In-Reply-To: <20060114182410.GA1108@galgenberg.net> References: <6eb82e0601140926n3d86e146m99aa9f47569b24aa@mail.gmail.com> <20060114182410.GA1108@galgenberg.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--jho1yZJdad60DJr+ Content-Type: multipart/mixed; boundary="OgqxwSJOaUobr8KG" Content-Disposition: inline --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ulrich Sp=F6rlein wrote: > I'm pretty sure it's the link_getaddr in af_link.c, there are two > possible fixes, depending on the requirements of link_addr() >=20 > If link_addr *needs* a terminating '\0', then we need to > malloc(strlen(addr) + 2), if it doesn't need the terminating zero, we > should get away with strncpy(temp + 1, addr, strlen(addr)) Yeah, seems to be a slow sunday today. Attached is the fix for this off-by-one bug. Ulrich Spoerlein --=20 PGP Key ID: F0DB9F44 Encrypted mail welcome! Fingerprint: F1CE D062 0CA9 ADE3 349B 2FE8 980A C6B5 F0DB 9F44 Which is worse: ignorance or apathy? Don't know. Don't care. --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: quoted-printable --- sbin/ifconfig/af_link.c.orig Sun Jan 15 19:14:54 2006 +++ sbin/ifconfig/af_link.c Sun Jan 15 19:15:04 2006 @@ -79,7 +79,7 @@ =20 if (which !=3D ADDR) errx(1, "can't set link-level netmask or broadcast"); - if ((temp =3D malloc(strlen(addr) + 1)) =3D=3D NULL) + if ((temp =3D malloc(strlen(addr) + 2)) =3D=3D NULL) errx(1, "malloc failed"); temp[0] =3D ':'; strcpy(temp + 1, addr); --OgqxwSJOaUobr8KG-- --jho1yZJdad60DJr+ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDypSV524iJyD+6d0RAuHGAJ0ZFvD3Gy8zY1mV6zdx9JTG0VHHtgCfe/rL l49omugyyGMdKmQqLO2cYg0= =tBo/ -----END PGP SIGNATURE----- --jho1yZJdad60DJr+--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060115182941.GA1182>