From owner-freebsd-hackers Sun Jan 12 15:00:44 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id PAA29739 for hackers-outgoing; Sun, 12 Jan 1997 15:00:44 -0800 (PST) Received: from labs.usn.blaze.net.au (labs.usn.blaze.net.au [203.17.53.30]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id PAA29734 for ; Sun, 12 Jan 1997 15:00:39 -0800 (PST) Received: (from davidn@localhost) by labs.usn.blaze.net.au (8.8.4/8.8.4) id NAA00564; Thu, 11 Jan 1996 13:09:39 +1100 (EST) Message-ID: Date: Thu, 11 Jan 1996 02:09:39 +0000 From: davidn@unique.usn.blaze.net.au (David Nugent) To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Cc: hackers@FreeBSD.org Subject: Re: unused variable in su References: <199701110142.CAA28453@xp11.frmug.org> <199701110834.TAA07745@genesis.atrad.adelaide.edu.au> X-Mailer: Mutt 0.56 Mime-Version: 1.0 In-Reply-To: ; from J Wunsch on Jan 11, 1997 13:14:24 +0100 Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk J Wunsch writes: > > pwd is recycled later, and shell is potentially reset later, so > > this is the 'correct' way to do it. Don't change it. > > Still, it's fairly obfuscated code. It could be better worded: IMHO, it is fine (and yes, it should be strncpy()). Using the return from str[n]cpy() is not obfuscation. YMMV. Like a lot of readability issues it depends on what you're used to and what you code yourself. > This would be less confusing for compilers and human readers. Perhaps a comment (gasp!) might help. Even with your "clearer" code the intent may not be obvious. I don't believe the compiler will care much either way. :-) I'll add one since I happen to be working on su. > Btw., shouldn't it better be a strncpy() anyway? Sure, /etc/shells is > at the mercy of the sysadmin, but he isn't unfailable. It is /etc/master.passwd in this case, but what you say is still true. In a setuid binary no less, but fortunately no "return" anywhere in main(). Regards, David Nugent - Unique Computing Pty Ltd - Melbourne, Australia Voice +61-3-9791-9547 Data/BBS +61-3-9792-3507 3:632/348@fidonet davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/