From 3ca9daaf8cc60f08d9a19a9f176866173e5398b7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 12 Apr 1997 18:57:31 +0000 Subject: Fix from FreeBSD (David Nugent ) Submitted by: Philippe Charnier Fixes name size limitation (was hardcoded to 8). Closes FreeBSD PR#3258 --- libexec/atrun/atrun.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'libexec/atrun') diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index 0d2e26647ba..16cc21030a4 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.3 1997/03/01 23:39:43 millert Exp $ */ +/* $OpenBSD: atrun.c,v 1.4 1997/04/12 18:57:30 millert Exp $ */ /* * atrun.c - run jobs queued by at; run with root privileges. @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include @@ -54,10 +56,18 @@ #include "pathnames.h" #include "atrun.h" +/* File scope defines */ + +#if (MAXLOGNAME-1) > UT_NAMESIZE +#define LOGNAMESIZE UT_NAMESIZE +#else +#define LOGNAMESIZE (MAXLOGNAME-1) +#endif + /* File scope variables */ static char *namep; -static char rcsid[] = "$OpenBSD: atrun.c,v 1.3 1997/03/01 23:39:43 millert Exp $"; +static char rcsid[] = "$OpenBSD: atrun.c,v 1.4 1997/04/12 18:57:30 millert Exp $"; static int debug = 0; /* Local functions */ @@ -109,7 +119,7 @@ run_file(filename, uid, gid) pid_t pid; int fd_out, fd_in; int queue; - char mailbuf[9]; + char mailbuf[LOGNAMESIZE + 1], fmt[49]; char *mailname = NULL; FILE *stream; int send_mail = 0; @@ -194,8 +204,10 @@ run_file(filename, uid, gid) (void)fcntl(fd_in, F_SETFD, fflags & ~FD_CLOEXEC); - if (fscanf(stream, "#!/bin/sh\n# atrun uid=%u gid=%u\n# mail %8s %d", - &nuid, &ngid, mailbuf, &send_mail) != 4) { + (void)snprintf(fmt, sizeof(fmt), + "#!/bin/sh\n# atrun uid=%%ld gid=%%ld\n# mail %%%ds %%d", + LOGNAMESIZE); + if (fscanf(stream, fmt, &nuid, &ngid, mailbuf, &send_mail) != 4) { syslog(LOG_ERR, "File %s is in wrong format - aborting", filename); exit(EXIT_FAILURE); -- cgit v1.2.3