From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14130 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] musl: bugfix getspnam_r negative Date: Thu, 16 May 2019 02:31:04 +0000 Message-ID: <1557973864-126747-1-git-send-email-chenjie6@huawei.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="209692"; mail-complaints-to="usenet@blaine.gmane.org" Cc: , chen jie To: Original-X-From: musl-return-14146-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 16 04:37:25 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 1hR6Gr-000sSH-CD for gllmg-musl@m.gmane.org; Thu, 16 May 2019 04:37:25 +0200 Original-Received: (qmail 6070 invoked by uid 550); 16 May 2019 02:37:22 -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 6034 invoked from network); 16 May 2019 02:37:21 -0000 X-Mailer: git-send-email 1.8.3.4 X-Originating-IP: [10.67.189.231] X-CFilter-Loop: Reflected Xref: news.gmane.org gmane.linux.lib.musl.general:14130 Archived-At: From: chen jie The /etc/shadow contain: sshd:*:11880:0:90:7:-1:-1:0 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