From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10193 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Undetected failures in getdomainname Date: Wed, 22 Jun 2016 12:31:51 -0400 Message-ID: <20160622163151.GP10893@brightrain.aerifal.cx> References: <576A491D.7030509@nicta.com.au> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1466613146 6267 80.91.229.3 (22 Jun 2016 16:32:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 Jun 2016 16:32:26 +0000 (UTC) Cc: musl@lists.openwall.com To: Matthew Fernandez Original-X-From: musl-return-10206-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jun 22 18:32:26 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 1bFl4a-00072q-3e for gllmg-musl@m.gmane.org; Wed, 22 Jun 2016 18:32:16 +0200 Original-Received: (qmail 32401 invoked by uid 550); 22 Jun 2016 16:32:13 -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 32381 invoked from network); 22 Jun 2016 16:32:13 -0000 Content-Disposition: inline In-Reply-To: <576A491D.7030509@nicta.com.au> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10193 Archived-At: 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. > 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. Rich