diff options
author | davidn <davidn@FreeBSD.org> | 1997-02-18 05:47:07 +0000 |
---|---|---|
committer | davidn <davidn@FreeBSD.org> | 1997-02-18 05:47:07 +0000 |
commit | 8feba284f5142f7caa4edaccb190cdce819fc48b (patch) | |
tree | 858311c19c41707f8b4484a7302b9264a646222d /usr.bin/at | |
parent | 8f26a5330a89c272f514bfb8c4320300ea592ddb (diff) | |
download | FreeBSD-src-8feba284f5142f7caa4edaccb190cdce819fc48b.zip FreeBSD-src-8feba284f5142f7caa4edaccb190cdce819fc48b.tar.gz |
Fix for hard-coded length of login name.
Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
Closes #PR bin/2755
Diffstat (limited to 'usr.bin/at')
-rw-r--r-- | usr.bin/at/at.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index 6930ae8..437ee5a 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -33,6 +33,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#include <sys/param.h> #include <ctype.h> #include <dirent.h> #include <errno.h> @@ -45,12 +46,19 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <utmp.h> #ifndef __FreeBSD__ #include <getopt.h> #else #include <locale.h> #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 */ |