From owner-freebsd-current@FreeBSD.ORG Sun Jan 15 18:29:46 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B91AF16A41F for ; Sun, 15 Jan 2006 18:29:46 +0000 (GMT) (envelope-from q@galgenberg.net) Received: from wrzx35.rz.uni-wuerzburg.de (wrzx35.rz.uni-wuerzburg.de [132.187.3.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id BB00F43D46 for ; Sun, 15 Jan 2006 18:29:45 +0000 (GMT) (envelope-from q@galgenberg.net) Received: from amavis.mail (amavis2.rz.uni-wuerzburg.de [132.187.3.47]) by wrzx35.rz.uni-wuerzburg.de (Postfix) with ESMTP id 05F53E7894; Sun, 15 Jan 2006 19:29:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by amavis.mail (Postfix) with ESMTP id EB4A01C9C; Sun, 15 Jan 2006 19:29:43 +0100 (CET) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by amavis.mail (Postfix) with ESMTP id C671C1CB8; Sun, 15 Jan 2006 19:29:43 +0100 (CET) Received: from frodo.galgenberg.net (wwsx14.win-screen.uni-wuerzburg.de [132.187.253.14]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id 8AF5B144943; Sun, 15 Jan 2006 19:29:43 +0100 (CET) Received: from coyote.q.local (gb-21-237.galgenberg.net [172.16.21.237]) by frodo.galgenberg.net (8.13.1/8.13.1) with ESMTP id k0FIThc0021101; Sun, 15 Jan 2006 19:29:43 +0100 (CET) (envelope-from q@galgenberg.net) Received: from roadrunner.q.local (roadrunner.q.local [192.168.0.148]) by coyote.q.local (8.13.4/8.13.4) with ESMTP id k0FITgpX022925; Sun, 15 Jan 2006 19:29:42 +0100 (CET) (envelope-from q@galgenberg.net) Received: from roadrunner.q.local (localhost [127.0.0.1]) by roadrunner.q.local (8.13.4/8.13.4) with ESMTP id k0FITguO021424; Sun, 15 Jan 2006 19:29:42 +0100 (CET) (envelope-from q@galgenberg.net) Received: (from q@localhost) by roadrunner.q.local (8.13.4/8.13.4/Submit) id k0FITfeI021423; Sun, 15 Jan 2006 19:29:41 +0100 (CET) (envelope-from q@galgenberg.net) Date: Sun, 15 Jan 2006 19:29:41 +0100 From: Ulrich Spoerlein To: Rong-En Fan , current@freebsd.org Message-ID: <20060115182941.GA1182@galgenberg.net> Mail-Followup-To: Rong-En Fan , current@freebsd.org References: <6eb82e0601140926n3d86e146m99aa9f47569b24aa@mail.gmail.com> <20060114182410.GA1108@galgenberg.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jho1yZJdad60DJr+" Content-Disposition: inline In-Reply-To: <20060114182410.GA1108@galgenberg.net> X-Virus-Scanned: by amavisd-new at uni-wuerzburg.de X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=8.0 tests= X-Spam-Level: Cc: Subject: [PATCH] Fix off-by-one bug in ifconfig's af_link.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jan 2006 18:29:46 -0000 --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+--