summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>2001-08-20 13:24:39 +0000
committerBrian Somers <brian@FreeBSD.org>2001-08-20 13:24:39 +0000
commitfee8e0724b96f65b1c5b143b33b4a00b4b3c92f7 (patch)
tree4af397f2f84ab2ab76a79d251069b1b105a455e0 /pw
parent33f0d61904154e94936202cc7c56f3ae19e0939a (diff)
downloadpw-darwin-fee8e0724b96f65b1c5b143b33b4a00b4b3c92f7.tar.gz
pw-darwin-fee8e0724b96f65b1c5b143b33b4a00b4b3c92f7.tar.zst
pw-darwin-fee8e0724b96f65b1c5b143b33b4a00b4b3c92f7.zip
Handle snprintf() returning -1.
MFC after: 2 weeks
Diffstat (limited to 'pw')
-rw-r--r--pw/grupd.c2
-rw-r--r--pw/pw_conf.c4
-rw-r--r--pw/pwupd.c2
3 files changed, 7 insertions, 1 deletions
diff --git a/pw/grupd.c b/pw/grupd.c
index edff76d..a2a0282 100644
--- a/pw/grupd.c
+++ b/pw/grupd.c
@@ -134,7 +134,7 @@ gr_update(struct group * grp, char const * group, int mode)
char *grbuf = NULL;
ENDGRENT();
- l = snprintf(pfx, sizeof pfx, "%s:", group);
+ snprintf(pfx, sizeof pfx, "%s:", group);
/*
* Update the group file
diff --git a/pw/pw_conf.c b/pw/pw_conf.c
index 0580091..e4c5a4a 100644
--- a/pw/pw_conf.c
+++ b/pw/pw_conf.c
@@ -420,6 +420,8 @@ write_userconfig(char const * file)
for (j = k = 0; j < _UC_MAXSHELLS && system_shells[j] != NULL; j++) {
char lbuf[64];
int l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", system_shells[j]);
+ if (l == -1)
+ l = 0;
if (l + k + 1 < len || extendline(&buf, &len, len + LNBUFSZ) != -1) {
strcpy(buf + k, lbuf);
k += l;
@@ -438,6 +440,8 @@ write_userconfig(char const * file)
for (j = k = 0; j < config.numgroups && config.groups[j] != NULL; j++) {
char lbuf[64];
int l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", config.groups[j]);
+ if (l == -1)
+ l = 0;
if (l + k + 1 < len || extendline(&buf, &len, len + 1024) != -1) {
strcpy(buf + k, lbuf);
k += l;
diff --git a/pw/pwupd.c b/pw/pwupd.c
index fef3662..ec29b9e 100644
--- a/pw/pwupd.c
+++ b/pw/pwupd.c
@@ -166,6 +166,8 @@ pw_update(struct passwd * pwd, char const * user, int mode)
else
fmtpwentry(pwbuf, pwd, PWF_PASSWD);
+ if (l == -1)
+ l = 0;
rc = fileupdate(getpwpath(_PASSWD), 0644, pwbuf, pfx, l, mode);
if (rc == 0) {