From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: rtweed@thoughtmachine.net, chen jie <chenjie6@huawei.com>
Subject: Re: [PATCH] musl: bugfix getspnam_r negative
Date: Thu, 16 May 2019 10:03:42 +0200 [thread overview]
Message-ID: <20190516080342.GE16415@port70.net> (raw)
In-Reply-To: <1557973864-126747-1-git-send-email-chenjie6@huawei.com>
* chenjie6@huawei.com <chenjie6@huawei.com> [2019-05-16 02:31:04 +0000]:
> From: chen jie <chenjie6@huawei.com>
>
> 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<chenjie6@huawei.com>
> ---
> 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
prev parent reply other threads:[~2019-05-16 8:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 2:31 chenjie6
2019-05-16 8:03 ` Szabolcs Nagy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190516080342.GE16415@port70.net \
--to=nsz@port70.net \
--cc=chenjie6@huawei.com \
--cc=musl@lists.openwall.com \
--cc=rtweed@thoughtmachine.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).