summaryrefslogtreecommitdiffstats
path: root/usr.bin/finger
diff options
context:
space:
mode:
authorjedgar <jedgar@FreeBSD.org>2001-01-20 00:26:32 +0000
committerjedgar <jedgar@FreeBSD.org>2001-01-20 00:26:32 +0000
commit73ff8fb47fd62018f224c61bc26645009cdae500 (patch)
tree97b76e5499e150202eef9ac8081ec74d8cf0a031 /usr.bin/finger
parent0dd50f934b2232082974229101e0df1d32e607a5 (diff)
downloadFreeBSD-src-73ff8fb47fd62018f224c61bc26645009cdae500.zip
FreeBSD-src-73ff8fb47fd62018f224c61bc26645009cdae500.tar.gz
Check strdup() return values
Reviewed by: kris
Diffstat (limited to 'usr.bin/finger')
-rw-r--r--usr.bin/finger/util.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c
index 7823ef4..eb91206 100644
--- a/usr.bin/finger/util.c
+++ b/usr.bin/finger/util.c
@@ -353,9 +353,12 @@ userinfo(pn, pw)
pn->realname = pn->office = pn->officephone = pn->homephone = NULL;
pn->uid = pw->pw_uid;
- pn->name = strdup(pw->pw_name);
- pn->dir = strdup(pw->pw_dir);
- pn->shell = strdup(pw->pw_shell);
+ if ((pn->name = strdup(pw->pw_name)) == NULL)
+ err(1, "strdup failed");
+ if ((pn->dir = strdup(pw->pw_dir)) == NULL)
+ err(1, "strdup failed");
+ if ((pn->shell = strdup(pw->pw_shell)) == NULL)
+ err(1, "strdup failed");
/* why do we skip asterisks!?!? */
(void)strncpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf));
@@ -380,7 +383,8 @@ userinfo(pn, pw)
}
}
*t = '\0';
- pn->realname = strdup(name);
+ if ((pn->realname = strdup(name)) == NULL)
+ err(1, "strdup failed");
pn->office = ((p = strsep(&bp, ",")) && *p) ?
strdup(p) : NULL;
pn->officephone = ((p = strsep(&bp, ",")) && *p) ?
OpenPOWER on IntegriCloud