From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 5 Jun 2013 10:09:27 -0400 To: 9fans@9fans.net Message-ID: In-Reply-To: References: <03dd9a6798effc7cf713d579f6bbc0e6@isd.dp.ua> <636BFA64-E5C9-417C-AD9E-E6BCEAACB02B@gmail.com> <51AF3F6A.8000605@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] lpdaemon Topicbox-Message-UUID: 63bbb37e-ead8-11e9-9d60-3106f5b1d025 > You're absolutely correct if the length of value to be copied is not > validated prior to the copy. Then, an invalid page could be hit if no > nil is present within the array or beyond. wrong. strncpy only copies up to the specified maximum. the code is ugly but correct. > To be verbose, my bypassing of strncpy is due to issues I've > encountered in multi-threaded code. e.g. Don't trust libc copy > functions in MT envs, always check post call. this sounds like your saying that because you had trouble in a multithreaded unix application, then without examining the code at hand, it is pronounced to have the same issue. that sounds like equivocation to me. the code is correct. and in all cases nul-terminated, and any unused bytes are 0. i only object to strncpy because it requires extra work. seprint, snprint are a bit heavy weight but tend to produce cleaner looking code. ymmv. - erik