From a5b2c458ca33ee80bb451db73ccc20b17fa1a057 Mon Sep 17 00:00:00 2001 From: mycroft Date: Sun, 26 Jul 1998 21:25:16 +0000 Subject: [PATCH] const poisoning. --- usr.bin/chpass/edit.c | 9 +++++---- usr.bin/chpass/pw_yp.c | 18 +++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index aad1fb3d03ce..52d653db7e42 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -1,4 +1,4 @@ -/* $NetBSD: edit.c,v 1.11 1998/02/04 15:21:53 christos Exp $ */ +/* $NetBSD: edit.c,v 1.12 1998/07/26 21:25:16 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: edit.c,v 1.11 1998/02/04 15:21:53 christos Exp $"); +__RCSID("$NetBSD: edit.c,v 1.12 1998/07/26 21:25:16 mycroft Exp $"); #endif #endif /* not lint */ @@ -132,7 +132,7 @@ display(tempname, fd, pw) *pw->pw_shell ? pw->pw_shell : _PATH_BSHELL); else list[E_SHELL].restricted = 1; - bp = pw->pw_gecos; + bp = strdup(pw->pw_gecos); p = strsep(&bp, ","); (void)fprintf(fp, "Full Name: %s\n", p ? p : ""); p = strsep(&bp, ","); @@ -212,8 +212,9 @@ bad: (void)fclose(fp); strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save) + 4; if (!(p = malloc(len))) err(1, "malloc"); - (void)snprintf(pw->pw_gecos = p, len, "%s,%s,%s,%s", list[E_NAME].save, + (void)snprintf(p, len, "%s,%s,%s,%s", list[E_NAME].save, list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save); + pw->pw_gecos = p; if (snprintf(buf, sizeof(buf), "%s:%s:%d:%d:%s:%lu:%lu:%s:%s:%s", diff --git a/usr.bin/chpass/pw_yp.c b/usr.bin/chpass/pw_yp.c index 6b042dda7841..361c14efacd7 100644 --- a/usr.bin/chpass/pw_yp.c +++ b/usr.bin/chpass/pw_yp.c @@ -1,4 +1,4 @@ -/* $NetBSD: pw_yp.c,v 1.13 1998/07/05 14:26:06 mrg Exp $ */ +/* $NetBSD: pw_yp.c,v 1.14 1998/07/26 21:25:16 mycroft Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)pw_yp.c 1.0 2/2/93"; #else -__RCSID("$NetBSD: pw_yp.c,v 1.13 1998/07/05 14:26:06 mrg Exp $"); +__RCSID("$NetBSD: pw_yp.c,v 1.14 1998/07/26 21:25:16 mycroft Exp $"); #endif #endif /* not lint */ @@ -168,13 +168,13 @@ pw_yp(pw, uid) } /* tell rpc.yppasswdd */ - yppasswd.newpw.pw_name = pw->pw_name; - yppasswd.newpw.pw_passwd= pw->pw_passwd; - yppasswd.newpw.pw_uid = pw->pw_uid; - yppasswd.newpw.pw_gid = pw->pw_gid; - yppasswd.newpw.pw_gecos = pw->pw_gecos; - yppasswd.newpw.pw_dir = pw->pw_dir; - yppasswd.newpw.pw_shell = pw->pw_shell; + yppasswd.newpw.pw_name = strdup(pw->pw_name); + yppasswd.newpw.pw_passwd = strdup(pw->pw_passwd); + yppasswd.newpw.pw_uid = pw->pw_uid; + yppasswd.newpw.pw_gid = pw->pw_gid; + yppasswd.newpw.pw_gecos = strdup(pw->pw_gecos); + yppasswd.newpw.pw_dir = strdup(pw->pw_dir); + yppasswd.newpw.pw_shell = strdup(pw->pw_shell); client = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, "udp"); if (client == NULL) {