From owner-svn-src-all@FreeBSD.ORG Sat Mar 13 21:15:53 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1811B1065673; Sat, 13 Mar 2010 21:15:53 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com [74.125.83.182]) by mx1.freebsd.org (Postfix) with ESMTP id CBB0A8FC12; Sat, 13 Mar 2010 21:15:52 +0000 (UTC) Received: by pvg3 with SMTP id 3so1057156pvg.13 for ; Sat, 13 Mar 2010 13:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=e/SI24IQKwQKSsJjlhaVN5NiPnAulR84UG5S86zCQg0=; b=BAU49C/prO8sCa4y/GDzhH6OvP1Ibfzf+Lu9cGP0QY5V+l5NqIeH9UEo+OQ4EGZ0po 3dH35oYf2xjKWTv2WMe0C74FV7C6BjWjibEoh2asoBndjCo0p2U73bHxEgkT1K4LQJi+ IGV2GZmQqdBgfv9jTckOS6VTdP7jHXgR7Idsk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=TPt56LRZqbNUlgkxCzy0hao3Tn0M5qUgUQF/bxIqbi8y28Au1miyrApRhWxpw0MwIk IfIrMnrhDKhYr1EtiCSI1bH7maWip6aGW8RqCXwmfUcEjmlucrkftiUY629ZTkF5Oia0 mrZC3oaSuqHEMRiGj9BLKzqNvA6V7pV1l0ElE= MIME-Version: 1.0 Received: by 10.142.2.25 with SMTP id 25mr2487885wfb.141.1268514952362; Sat, 13 Mar 2010 13:15:52 -0800 (PST) In-Reply-To: <7d6fde3d1003131313l3559b6dbt1566fb23be150408@mail.gmail.com> References: <201003131108.o2DB8vmu001454@svn.freebsd.org> <7d6fde3d1003131313l3559b6dbt1566fb23be150408@mail.gmail.com> Date: Sat, 13 Mar 2010 13:15:52 -0800 Message-ID: <7d6fde3d1003131315m361188abj1b7371b37f064b26@mail.gmail.com> From: Garrett Cooper To: Bruce Cran Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r205118 - head/sbin/sysctl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Mar 2010 21:15:53 -0000 On Sat, Mar 13, 2010 at 1:13 PM, Garrett Cooper wrote: > On Sat, Mar 13, 2010 at 3:08 AM, Bruce Cran wrote: >> Author: brucec >> Date: Sat Mar 13 11:08:57 2010 >> New Revision: 205118 >> URL: http://svn.freebsd.org/changeset/base/205118 >> >> Log: >> =A0Free the memory allocated via strdup. >> >> =A0PR: =A0 =A0 =A0 =A0 =A0 bin/113881 >> =A0Submitted by: Alexander Drozdov =A0dzal_mail mtu-net.ru >> =A0Approved by: =A0rrs (mentor) >> =A0MFC after: =A0 =A01 week >> >> Modified: >> =A0head/sbin/sysctl/sysctl.c >> >> Modified: head/sbin/sysctl/sysctl.c >> =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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/sbin/sysctl/sysctl.c =A0 Sat Mar 13 11:06:47 2010 =A0 =A0 =A0 = =A0(r205117) >> +++ head/sbin/sysctl/sysctl.c =A0 Sat Mar 13 11:08:57 2010 =A0 =A0 =A0 = =A0(r205118) >> @@ -382,6 +382,7 @@ S_timeval(int l2, void *p) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (*p2 =3D=3D '\n') >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*p2 =3D '\0'; >> =A0 =A0 =A0 =A0fputs(p1, stdout); >> + =A0 =A0 =A0 free(p1); >> =A0 =A0 =A0 =A0return (0); >> =A0} > > =A0 =A0strdup(3) can fail in that section of code, thus the fputs(3) > could segfault: > > [gcooper@bayonetta ~]$ cat foo.c > #include > #include > > int main(void) { > =A0 =A0 =A0 =A0char *foo =3D NULL; > =A0 =A0 =A0 =A0fputs(foo, stdout); > =A0 =A0 =A0 =A0free(foo); > =A0 =A0 =A0 =A0return 0; > } > [gcooper@bayonetta ~]$ gcc -o foo foo.c > [gcooper@bayonetta ~]$ ./foo > Segmentation fault: 11 (core dumped) > > =A0 =A0Could a... > > =A0 =A0if (p1 =3D=3D NULL) > > =A0 =A0... be added before the fputs(3) please? Sorry... inverted logic. if (p1 !=3D NULL) :P... Thanks, -Garrett