Skip site navigation (1)Skip section navigation (2)
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
Message-ID:  <Mutt.19960111020939.davidn@labs.blaze.net.au>
In-Reply-To: <Mutt.19970111131424.j@uriah.heep.sax.de>; from J Wunsch on Jan 11, 1997 13:14:24 %2B0100
References:  <199701110142.CAA28453@xp11.frmug.org> <199701110834.TAA07745@genesis.atrad.adelaide.edu.au> <Mutt.19970111131424.j@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Mutt.19960111020939.davidn>