Date: Tue, 10 Nov 2009 18:59:36 +0200 From: Kostik Belousov <kostikbel@gmail.com> To: Nate Eldredge <nate@thatsmathematics.com> Cc: Alexander Best <alexbestms@wwu.de>, Giorgos Keramidas <keramida@freebsd.org>, freebsd-hackers@freebsd.org, Dag-Erling Sm?rgrav <des@des.no> Subject: Re: [patch] burncd: honour for envar SPEED Message-ID: <20091110165936.GC2331@deviant.kiev.zoral.com.ua> In-Reply-To: <Pine.GSO.4.64.0911100756320.5432@zeno.ucsd.edu> References: <permail-200911101550071e86ffa800005ac8-a_best01@message-id.uni-muenster.de> <Pine.GSO.4.64.0911100756320.5432@zeno.ucsd.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Tue, Nov 10, 2009 at 08:03:26AM -0800, Nate Eldredge wrote: > On Tue, 10 Nov 2009, Alexander Best wrote: > > >ps: would be nice if strcasecmp could protect itself from segfault with > >one or > >both of the args being NULL. > > I disagree. What do you think it should do instead? Return 0? If it > did, would you have found your bug? > > The same argument could be made for any of the string.h functions, but I > don't think it actually holds water. Such checks add overhead, and only > provide an illusion of safety. Sure, strcasecmp could avoid causing the > segfault itself, but at the cost of letting a broken program continue and > possibly cause more damage. It could call abort(), but then you'd just > have the same result (program terminates) with a different signal, and > doing your check in software rather than letting the MMU hardware do it. > It could print a message, but that pollutes the program's output, and 15 > seconds debugging the core dump will reveal the problem anyway. > > Having a library function "protect itself" in this manner is not actually > helpful, IMHO. I remember System V to actually map zero page at 0, thus causing all string functions to behave like it was supplied empty string when argument is NULL. I believe Solaris still provides the library that could be LD_PRELOADed for the same effect. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkr5m/cACgkQC3+MBN1Mb4jYmgCg5jHeHRzSzO+PvtkNvOxyjYzT od4An0/l2yjXKYZdvKtAiIaIeUvi0xlt =u16l -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091110165936.GC2331>
