From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10205 Path: news.gmane.org!not-for-mail From: Matthew Fernandez Newsgroups: gmane.linux.lib.musl.general Subject: Re: Undetected failures in getdomainname Date: Thu, 23 Jun 2016 10:17:06 +1000 Message-ID: <576B2A82.9010602@nicta.com.au> References: <576A491D.7030509@nicta.com.au> <20160622163151.GP10893@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466641054 18847 80.91.229.3 (23 Jun 2016 00:17:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jun 2016 00:17:34 +0000 (UTC) Cc: To: Rich Felker Original-X-From: musl-return-10218-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jun 23 02:17:33 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1bFsKp-0004AL-DD for gllmg-musl@m.gmane.org; Thu, 23 Jun 2016 02:17:31 +0200 Original-Received: (qmail 16150 invoked by uid 550); 23 Jun 2016 00:17:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 16132 invoked from network); 23 Jun 2016 00:17:27 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: <20160622163151.GP10893@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:10205 Archived-At: On 23/06/16 02:31, Rich Felker wrote: > On Wed, Jun 22, 2016 at 06:15:25PM +1000, Matthew Fernandez wrote: >> Hi all, >> >> In the tip at time of writing >> (6cec7bc57f599f43f4041cec2093e3c9231dbaab) there are a couple of >> syscalls that are implemented by calling uname, notably gethostname >> and getdomainname. In gethostname, the return value of uname is >> checked and the code returns early if uname fails. However, in >> getdomainname the return value of uname is ignored. I think it >> should be following the same pattern as gethostname. Is this >> correct? > > In practice I don't think the difference matters unless someone has > hooked uname to fail (e.g. seccomp or perhaps LSMs), since the syscall > itself can't fail. It wouldn't hurt to make them consistent though. Good point. I hadn't factored in that the only uname failure case is when t= he buffer is invalid, which can never occur when called from getdomainname. >> Also, gethostname rolls its own strcpy, while getdomainname just >> calls strcpy. However, maybe there is a good reason for this. > > As written the behaviors are different. gethostname truncates while > getdomainname returns an error on excessive length. The former is > mandated by POSIX; the latter is documented (but not clearly specified > as a requirement vs just being an optional failure) in the Linux man > page, since getdomainname is not a standard function. Ah, nice. Learned something new today :) Thanks, Rich. ________________________________ The information in this e-mail may be confidential and subject to legal pro= fessional privilege and/or copyright. National ICT Australia Limited accept= s no liability for any damage caused by this email or its attachments.