From a88368cfdf5c8e01d6ba9e9b06bd326399cc60a8 Mon Sep 17 00:00:00 2001 From: David Nugent Date: Tue, 18 Feb 1997 05:47:07 +0000 Subject: Fix for hard-coded length of login name. Submitted by: Philippe Charnier Closes #PR bin/2755 --- usr.bin/at/at.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index 6930ae8ddb4cc..437ee5a09cc8f 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -45,12 +46,19 @@ #include #include #include +#include #ifndef __FreeBSD__ #include #else #include #endif +#if (MAXLOGNAME-1) > UT_NAMESIZE +#define LOGNAMESIZE UT_NAMESIZE +#else +#define LOGNAMESIZE (MAXLOGNAME-1) +#endif + /* Local headers */ #include "at.h" @@ -306,7 +314,7 @@ writefile(time_t runtimer, char queue) mailname = getenv("LOGNAME"); if ((mailname == NULL) || (mailname[0] == '\0') - || (strlen(mailname) > 8) || (getpwnam(mailname)==NULL)) + || (strlen(mailname) > LOGNAMESIZE) || (getpwnam(mailname)==NULL)) { pass_entry = getpwuid(real_uid); if (pass_entry != NULL) @@ -319,8 +327,8 @@ writefile(time_t runtimer, char queue) if (fpin == NULL) perr("Cannot open input file"); } - fprintf(fp, "#!/bin/sh\n# atrun uid=%ld gid=%ld\n# mail %8s %d\n", - (long) real_uid, (long) real_gid, mailname, send_mail); + fprintf(fp, "#!/bin/sh\n# atrun uid=%ld gid=%ld\n# mail %*s %d\n", + (long) real_uid, (long) real_gid, LOGNAMESIZE, mailname, send_mail); /* Write out the umask at the time of invocation */ -- cgit v1.3