diff options
| author | Chris Longros <chris.longros@gmail.com> | 2026-04-29 04:06:29 +0000 |
|---|---|---|
| committer | Kyle Evans <kevans@FreeBSD.org> | 2026-04-29 04:06:29 +0000 |
| commit | 91bfba010bcda665cc24a76af631cc85fcb0c688 (patch) | |
| tree | a610acb25ab68f524a2592e16f85b5f27f09e53c | |
| parent | 2c2ec6bbc9cc7762a250ffe903bda6c2e44d25ff (diff) | |
cron: log when a crontab path is too long
Log via syslog when snprintf truncates the crontab path, instead of
silently skipping the entry.
Signed-off-by: Christos Longros <chris.longros@gmail.com>
Reviewed by: bcr, kevans
Differential Revision: https://reviews.freebsd.org/D56235
| -rw-r--r-- | usr.sbin/cron/cron/cron.8 | 11 | ||||
| -rw-r--r-- | usr.sbin/cron/cron/database.c | 6 |
2 files changed, 13 insertions, 4 deletions
diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8 index 23a295393df5..f1a6a30d4cb5 100644 --- a/usr.sbin/cron/cron/cron.8 +++ b/usr.sbin/cron/cron/cron.8 @@ -19,7 +19,7 @@ .\" .\" $Id: cron.8,v 1.2 1998/08/14 00:32:36 vixie Exp $ .\" -.Dd January 20, 2026 +.Dd April 29, 2026 .Dt CRON 8 .Os .Sh NAME @@ -227,7 +227,14 @@ configuration file for .It Pa /usr/local/etc/cron.d Directory for third-party package provided crontab files. .It Pa /var/cron/tabs -Directory for personal crontab files +Directory for personal crontab files. +Internally the daemon constructs the relative path +.Pa tabs/ Ns Ar filename , +which must fit within +.Dv MAXNAMLEN +bytes; in practice this allows filenames up to 250 bytes. +Longer entries are skipped and a diagnostic is logged via +.Xr syslog 3 . .El .Sh SEE ALSO .Xr crontab 1 , diff --git a/usr.sbin/cron/cron/database.c b/usr.sbin/cron/cron/database.c index 35e5fad3524d..234b5ef7fdd6 100644 --- a/usr.sbin/cron/cron/database.c +++ b/usr.sbin/cron/cron/database.c @@ -166,8 +166,10 @@ load_database(cron_db *old_db) fname[sizeof(fname)-1] = '\0'; if (snprintf(tabname, sizeof tabname, CRON_TAB(fname)) - >= sizeof(tabname)) - continue; /* XXX log? */ + >= (int)sizeof(tabname)) { + log_it("CRON", getpid(), "TABNAME TOO LONG", fname); + continue; + } process_crontab(fname, fname, tabname, &statbuf, &new_db, old_db); |
