From 7a9b19976de61d2609ca55dc6bd117f28cc98ef0 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sat, 17 Aug 2013 06:54:21 +0000 Subject: [PATCH] Use %lld and cast to (long long) when printing time_t values and atoll() when parsing them. Add a couple [ug]id_t --> u_int casts for consistency with rest of code. Based on a diff from Nathanael Rensen (nathanael (at) polymorpheus.com) --- src/lib/libutil/passwd.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/libutil/passwd.c b/src/lib/libutil/passwd.c index 774dff86..26db941e 100644 --- a/src/lib/libutil/passwd.c +++ b/src/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.51 2013/08/06 22:47:43 millert Exp $ */ +/* $OpenBSD: passwd.c,v 1.52 2013/08/17 06:54:21 guenther Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -347,19 +347,20 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, const struct passwd *opw) pw_error(NULL, 0, 1); } } - (void)fprintf(to, "%s:%s:%u:%u:%s:%d:%d:%s:%s:%s\n", + (void)fprintf(to, "%s:%s:%u:%u:%s:%lld:%lld:%s:%s:%s\n", pw->pw_name, pw->pw_passwd, (u_int)pw->pw_uid, - (u_int)pw->pw_gid, pw->pw_class, pw->pw_change, - pw->pw_expire, pw->pw_gecos, pw->pw_dir, + (u_int)pw->pw_gid, pw->pw_class, (long long)pw->pw_change, + (long long)pw->pw_expire, pw->pw_gecos, pw->pw_dir, pw->pw_shell); done = 1; if (ferror(to)) goto fail; } if (!done) - (void)fprintf(to, "%s:%s:%u:%u:%s:%d:%d:%s:%s:%s\n", - pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid, - pw->pw_class, pw->pw_change, pw->pw_expire, pw->pw_gecos, + (void)fprintf(to, "%s:%s:%u:%u:%s:%lld:%lld:%s:%s:%s\n", + pw->pw_name, pw->pw_passwd, (u_int)pw->pw_uid, + (u_int)pw->pw_gid, pw->pw_class, (long long)pw->pw_change, + (long long)pw->pw_expire, pw->pw_gecos, pw->pw_dir, pw->pw_shell); if (ferror(to)) @@ -426,12 +427,12 @@ pw_scan(char *bp, struct passwd *pw, int *flags) pw->pw_class = strsep(&bp, ":"); /* class */ if (!(p = strsep(&bp, ":"))) /* change */ goto fmt; - pw->pw_change = atol(p); + pw->pw_change = atoll(p); if ((*p == '\0') && (flags != (int *)NULL)) *flags |= _PASSWORD_NOCHG; if (!(p = strsep(&bp, ":"))) /* expire */ goto fmt; - pw->pw_expire = atol(p); + pw->pw_expire = atoll(p); if ((*p == '\0') && (flags != (int *)NULL)) *flags |= _PASSWORD_NOEXP; pw->pw_gecos = strsep(&bp, ":"); /* gecos */