summaryrefslogtreecommitdiffstats
path: root/usr.bin/mail/v7.local.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mail/v7.local.c')
-rw-r--r--usr.bin/mail/v7.local.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/usr.bin/mail/v7.local.c b/usr.bin/mail/v7.local.c
index ade3cbd..03f2775 100644
--- a/usr.bin/mail/v7.local.c
+++ b/usr.bin/mail/v7.local.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$FreeBSD$";
#endif /* not lint */
/*
@@ -52,15 +56,16 @@ static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93";
* mail is queued).
*/
void
-findmail(user, buf)
+findmail(user, buf, buflen)
char *user, *buf;
+ int buflen;
{
char *tmp = getenv("MAIL");
if (tmp == NULL)
- (void)sprintf(buf, "%s/%s", _PATH_MAILDIR, user);
+ (void)snprintf(buf, buflen, "%s/%s", _PATH_MAILDIR, user);
else
- (void)strcpy(buf, tmp);
+ (void)strlcpy(buf, tmp, buflen);
}
/*
@@ -71,7 +76,7 @@ demail()
{
if (value("keep") != NOSTR || rm(mailname) < 0)
- close(creat(mailname, 0600));
+ close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
}
/*
@@ -81,8 +86,14 @@ char *
username()
{
char *np;
+ uid_t uid;
if ((np = getenv("USER")) != NOSTR)
return np;
- return getname(getuid());
+ if ((np = getenv("LOGNAME")) != NOSTR)
+ return np;
+ if ((np = getname(uid = getuid())) != NOSTR)
+ return np;
+ printf("Cannot associate a name with uid %u\n", (unsigned)uid);
+ return NOSTR;
}
OpenPOWER on IntegriCloud