svn commit: r305429 - in stable/9/usr.sbin/cron: cron crontab

Ed Maste emaste at FreeBSD.org
Mon Sep 5 17:56:54 UTC 2016


Author: emaste
Date: Mon Sep  5 17:56:52 2016
New Revision: 305429
URL: https://svnweb.freebsd.org/changeset/base/305429

Log:
  MFC r305269: cron: use existing maximum username constant MAXLOGNAME
  
  Previously cron had its own maximum username length limit, which was
  smaller than the system's MAXLOGNAME. This could lead to crontab -u
  updating the wrong user's crontab (if the name was truncated, and
  matched another user).
  
  PR:		212305
  Reported by:	Andrii Kuzik

Modified:
  stable/9/usr.sbin/cron/cron/cron.h
  stable/9/usr.sbin/cron/crontab/crontab.c
Directory Properties:
  stable/9/usr.sbin/cron/   (props changed)
  stable/9/usr.sbin/cron/crontab/   (props changed)

Modified: stable/9/usr.sbin/cron/cron/cron.h
==============================================================================
--- stable/9/usr.sbin/cron/cron/cron.h	Mon Sep  5 17:20:12 2016	(r305428)
+++ stable/9/usr.sbin/cron/cron/cron.h	Mon Sep  5 17:56:52 2016	(r305429)
@@ -73,7 +73,6 @@
 #define	MAX_COMMAND	1000	/* max length of internally generated cmd */
 #define	MAX_ENVSTR	1000	/* max length of envvar=value\0 strings */
 #define	MAX_TEMPSTR	100	/* obvious */
-#define	MAX_UNAME	20	/* max length of username, should be overkill */
 #define	ROOT_UID	0	/* don't change this, it really must be root */
 #define	ROOT_USER	"root"	/* ditto */
 #define	SYS_NAME	"*system*" /* magic owner name for system crontab */

Modified: stable/9/usr.sbin/cron/crontab/crontab.c
==============================================================================
--- stable/9/usr.sbin/cron/crontab/crontab.c	Mon Sep  5 17:20:12 2016	(r305428)
+++ stable/9/usr.sbin/cron/crontab/crontab.c	Mon Sep  5 17:56:52 2016	(r305429)
@@ -28,6 +28,7 @@ static const char rcsid[] =
 
 #define	MAIN_PROGRAM
 
+#include <sys/param.h>
 #include "cron.h"
 #include <errno.h>
 #include <fcntl.h>
@@ -57,7 +58,7 @@ static char	*Options[] = { "???", "list"
 
 
 static	PID_T		Pid;
-static	char		User[MAX_UNAME], RealUser[MAX_UNAME];
+static	char		User[MAXLOGNAME], RealUser[MAXLOGNAME];
 static	char		Filename[MAX_FNAME];
 static	FILE		*NewCrontab;
 static	int		CheckErrorCount;


More information about the svn-src-stable-9 mailing list