From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14132 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] musl: bugfix getspnam_r negative Date: Thu, 16 May 2019 10:03:42 +0200 Message-ID: <20190516080342.GE16415@port70.net> References: <1557973864-126747-1-git-send-email-chenjie6@huawei.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="167501"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: rtweed@thoughtmachine.net, chen jie To: musl@lists.openwall.com Original-X-From: musl-return-14148-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 16 10:03:57 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hRBMr-000hMy-6c for gllmg-musl@m.gmane.org; Thu, 16 May 2019 10:03:57 +0200 Original-Received: (qmail 7773 invoked by uid 550); 16 May 2019 08:03:54 -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 7755 invoked from network); 16 May 2019 08:03:54 -0000 Mail-Followup-To: musl@lists.openwall.com, rtweed@thoughtmachine.net, chen jie Content-Disposition: inline In-Reply-To: <1557973864-126747-1-git-send-email-chenjie6@huawei.com> Xref: news.gmane.org gmane.linux.lib.musl.general:14132 Archived-At: * chenjie6@huawei.com [2019-05-16 02:31:04 +0000]: > From: chen jie > > The /etc/shadow contain: > sshd:*:11880:0:90:7:-1:-1:0 note that it is not documented what -1 day means here. http://man7.org/linux/man-pages/man5/shadow.5.html glibc uses -1 internally to mark empty fields and parses the field as signed int, so it happens to work, but you may want to fix your /etc/shadow to match the specs. > the *s can not ++; __parsespent will not keep going down > > Signed-off-by: jie chen > --- > src/passwd/getspnam_r.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/src/passwd/getspnam_r.c b/src/passwd/getspnam_r.c > index 541e8531..1cb55bcd 100644 > --- a/src/passwd/getspnam_r.c > +++ b/src/passwd/getspnam_r.c > @@ -15,8 +15,16 @@ > static long xatol(char **s) > { > long x; > + int sign; > + > if (**s == ':' || **s == '\n') return -1; > + > + sign = (int)(unsigned char)**s; > + if (sign == '-' || sign == '+') ++*s; > + > for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0'); > + > + if (sign == '-') return -x; > return x; > } > > -- > 2.18.GIT