Date: Sun, 12 Jan 1997 12:47:49 +1030 (CST) From: Michael Smith <msmith@atrad.adelaide.edu.au> To: terry@lambert.org (Terry Lambert) Cc: joerg_wunsch@uriah.heep.sax.de, hackers@freebsd.org Subject: Re: unused variable in su Message-ID: <199701120217.MAA09886@genesis.atrad.adelaide.edu.au> In-Reply-To: <199701111939.MAA24005@phaeton.artisoft.com> from Terry Lambert at "Jan 11, 97 12:39:07 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
Terry Lambert stands accused of saying: > > Personally, I'd use strdup() istead of an auto buffer to allocate > the buffer at whatever size is necessary... ie: get rid of shellbuf > entirely and replace: > > shell = strcpy(shellbuf, pwd->pw_shell); > with: > shell = strdup( pwd->pw_shell); > > But, hey, that's me, using strdup() for what it was intended to do. You could, however, try reading the code in question, and note that shell is potentially reassigned several times. You would either have to record whether it was pointing at a strdup'd string as opposed to the statically-assigned cpp constant, or you could unconditionally strdup every time and always free it before reassigning. Personally, I think that the original code is the most readable alternative. > Terry Lambert -- ]] Mike Smith, Software Engineer msmith@gsoft.com.au [[ ]] Genesis Software genesis@gsoft.com.au [[ ]] High-speed data acquisition and (GSM mobile) 0411-222-496 [[ ]] realtime instrument control. (ph) +61-8-8267-3493 [[ ]] Unix hardware collector. "Where are your PEZ?" The Tick [[
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701120217.MAA09886>