From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 3 05:09:24 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19B25106564A; Mon, 3 Jan 2011 05:09:23 +0000 (UTC) (envelope-from jkh@turbofuzz.com) Received: from mail.brierdr.com (mail.brierdr.com [208.71.156.155]) by mx1.freebsd.org (Postfix) with ESMTP id B83F48FC18; Mon, 3 Jan 2011 05:09:23 +0000 (UTC) Received: from 208-106-35-98.static.sonic.net (208-106-35-98.static.sonic.net [208.106.35.98]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.brierdr.com (Postfix) with ESMTPS id B585D164830; Sun, 2 Jan 2011 20:37:23 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: multipart/signed; boundary=Apple-Mail-296-42958711; protocol="application/pkcs7-signature"; micalg=sha1 From: "Jordan K. Hubbard" In-Reply-To: Date: Sun, 2 Jan 2011 20:50:54 -0800 Message-Id: <6DCC53BA-D20A-4593-B3B0-1389734AD308@turbofuzz.com> References: To: Eitan Adler X-Mailer: Apple Mail (2.1082) X-Mailman-Approved-At: Mon, 03 Jan 2011 05:39:46 +0000 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: joe@freebsd.org, jkh@freebsd.org, hackers@freebsd.org, phk@freebsd.org Subject: Re: [patch] should crunchgen use basename(3) instead of homebrew code? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jan 2011 05:09:24 -0000 --Apple-Mail-296-42958711 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Wow. A couple of questions. 1. Is it really worth messing with code as old as crunchgen(1) at all? = Seriously. What's there isn't exactly "broken", and it seems like = needlessly walking into a vampire's crypt without so much as a stake or = clove of garlic on your person. Only something bad can happen. 2. basename(3) also strips trailing '/' characters, which the code you = are replacing does not. Does this actually matter? Hell if I know, I = haven't looked at the inputs to that code in ages and I have enough = common sense to stay out of musty crypts, so I'm not going to look, = either. :) - Jordan On Jan 1, 2011, at 11:37 PM, Eitan Adler wrote: > I'm not sure about this patch because of the behavior change of > - slash =3D strrchr(path, '/'); > - basename =3D slash? slash+1 : path; > + bn =3D basename(slash); >=20 > CCed to the last few people to touch the relevant code (via svn = praise) >=20 > Index: crunched_main.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 > --- crunched_main.c (revision 216884) > +++ crunched_main.c (working copy) > @@ -33,6 +33,7 @@ > * or calls one of them based on argv[1]. This allows the testing = of > * the crunched binary without creating all the links. > */ > +#include > #include > #include > #include > @@ -47,22 +48,21 @@ >=20 > int main(int argc, char **argv, char **envp) > { > - char *slash, *basename; > + char *slash, *bn; > struct stub *ep; >=20 > if(argv[0] =3D=3D NULL || *argv[0] =3D=3D '\0') > crunched_usage(); >=20 > - slash =3D strrchr(argv[0], '/'); > - basename =3D slash? slash+1 : argv[0]; > + bn =3D basename(argv[0]); >=20 > for(ep=3Dentry_points; ep->name !=3D NULL; ep++) > - if(!strcmp(basename, ep->name)) break; > + if(!strcmp(bn, ep->name)) break; >=20 > if(ep->name) > return ep->f(argc, argv, envp); > else { > - fprintf(stderr, "%s: %s not compiled in\n", EXECNAME, basename); > + fprintf(stderr, "%s: %s not compiled in\n", EXECNAME, bn); > crunched_usage(); > } > } > @@ -70,14 +70,13 @@ >=20 > int crunched_here(char *path) > { > - char *slash, *basename; > + char *slash, *bn; > struct stub *ep; >=20 > - slash =3D strrchr(path, '/'); > - basename =3D slash? slash+1 : path; > + bn =3D basename(slash); >=20 > for(ep=3Dentry_points; ep->name !=3D NULL; ep++) > - if(!strcmp(basename, ep->name)) > + if(!strcmp(bn, ep->name)) > return 1; > return 0; > } >=20 >=20 > --=20 > Eitan Adler --Apple-Mail-296-42958711--