summaryrefslogtreecommitdiffstats
path: root/chpass/pw_copy.c
diff options
context:
space:
mode:
authorMike Barcroft <mike@FreeBSD.org>2001-07-26 23:27:10 +0000
committerMike Barcroft <mike@FreeBSD.org>2001-07-26 23:27:10 +0000
commit2e7897495782bf04835cf18c52dbcfec3fcfe61e (patch)
tree84cf1d2449e5e61af0b1267bb9ce8b2143fbc334 /chpass/pw_copy.c
parentff4aa702015e5d6b3863c90eba93e78bb2e26a23 (diff)
downloadpw-darwin-2e7897495782bf04835cf18c52dbcfec3fcfe61e.tar.gz
pw-darwin-2e7897495782bf04835cf18c52dbcfec3fcfe61e.tar.zst
pw-darwin-2e7897495782bf04835cf18c52dbcfec3fcfe61e.zip
Prevent chpass(1) from writing -1 in the UID or GID fields
in the password file by properly casting integers. PR: 27757 Reviewed by: des Approved by: des MFC after: 4 days
Diffstat (limited to 'chpass/pw_copy.c')
-rw-r--r--chpass/pw_copy.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/chpass/pw_copy.c b/chpass/pw_copy.c
index 5d5a7de..d475757 100644
--- a/chpass/pw_copy.c
+++ b/chpass/pw_copy.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#ifndef lint
@@ -64,8 +66,8 @@ pw_copy(ffd, tfd, pw)
char chgstr[20];
char expstr[20];
- snprintf(uidstr, sizeof(uidstr), "%d", pw->pw_uid);
- snprintf(gidstr, sizeof(gidstr), "%d", pw->pw_gid);
+ snprintf(uidstr, sizeof(uidstr), "%lu", (unsigned long)pw->pw_uid);
+ snprintf(gidstr, sizeof(gidstr), "%lu", (unsigned long)pw->pw_gid);
snprintf(chgstr, sizeof(chgstr), "%ld", (long)pw->pw_change);
snprintf(expstr, sizeof(expstr), "%ld", (long)pw->pw_expire);