summaryrefslogtreecommitdiff
path: root/usr.bin/newsyslog/newsyslog.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
commit315054f4737a39489e0a14f3a92bff61f1592832 (patch)
tree62bf010653374ce09b6beb4dfa0414a91457233b /usr.bin/newsyslog/newsyslog.c
parent79e3d817585ca08a91e30ad14abe43e2ab70295f (diff)
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.bin/newsyslog/newsyslog.c')
-rw-r--r--usr.bin/newsyslog/newsyslog.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index 2527c5a87d8..95bcdcfd785 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.92 2013/11/26 13:19:07 deraadt Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.93 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 1999, 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -90,7 +90,7 @@
#define SENDMAIL "/usr/lib/sendmail"
#endif
-#include <sys/param.h>
+#include <sys/param.h> /* DEV_BSIZE */
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -153,7 +153,7 @@ int monitormode = 0; /* Don't do monitoring by default */
int force = 0; /* Force the logs to be rotated */
char *conf = CONF; /* Configuration file to use */
time_t timenow;
-char hostname[MAXHOSTNAMELEN]; /* Hostname */
+char hostname[HOST_NAME_MAX+1]; /* Hostname */
char *daytime; /* timenow in human readable form */
char *arcdir; /* Dir to put archives in (if it exists) */
@@ -648,7 +648,7 @@ parse_file(int *nentries)
break;
if (*q == '/') {
*(parse = son(parse)) = '\0';
- if (strlen(q) >= MAXPATHLEN)
+ if (strlen(q) >= PATH_MAX)
errx(1, "%s:%d: pathname too long: %s",
conf, lineno, q);
working->pidfile = strdup(q);
@@ -714,17 +714,17 @@ parse_file(int *nentries)
} else
working->backdir = NULL;
- /* Make sure we can't oflow MAXPATHLEN */
+ /* Make sure we can't oflow PATH_MAX */
if (working->backdir != NULL) {
if (snprintf(line, sizeof(line), "%s/%s.%d%s",
working->backdir, working->logbase,
- working->numlogs, COMPRESS_POSTFIX) >= MAXPATHLEN)
+ working->numlogs, COMPRESS_POSTFIX) >= PATH_MAX)
errx(1, "%s:%d: pathname too long: %s",
conf, lineno, q);
} else {
if (snprintf(line, sizeof(line), "%s.%d%s",
working->log, working->numlogs, COMPRESS_POSTFIX)
- >= MAXPATHLEN)
+ >= PATH_MAX)
errx(1, "%s:%d: pathname too long: %s",
conf, lineno, working->log);
}
@@ -749,7 +749,7 @@ missing_field(char *p, char *errline, int lineno)
void
rotate(struct conf_entry *ent, const char *oldlog)
{
- char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix;
+ char file1[PATH_MAX], file2[PATH_MAX], *suffix;
int numdays = ent->numlogs - 1;
int done = 0;
@@ -798,7 +798,7 @@ rotate(struct conf_entry *ent, const char *oldlog)
void
dotrim(struct conf_entry *ent)
{
- char file1[MAXPATHLEN], file2[MAXPATHLEN], oldlog[MAXPATHLEN];
+ char file1[PATH_MAX], file2[PATH_MAX], oldlog[PATH_MAX];
int fd;
/* Is there a separate backup dir? */
@@ -871,7 +871,7 @@ log_trim(char *log)
void
compress_log(struct conf_entry *ent)
{
- char *base, tmp[MAXPATHLEN];
+ char *base, tmp[PATH_MAX];
pid_t pid;
if (ent->backdir != NULL)
@@ -913,7 +913,7 @@ sizefile(struct stat *sb)
int
age_old_log(struct conf_entry *ent)
{
- char file[MAXPATHLEN];
+ char file[PATH_MAX];
struct stat sb;
if (ent->backdir != NULL)
@@ -967,7 +967,7 @@ isnumberstr(char *string)
int
domonitor(struct conf_entry *ent)
{
- char fname[MAXPATHLEN], *flog, *p, *rb = NULL;
+ char fname[PATH_MAX], *flog, *p, *rb = NULL;
struct stat sb, tsb;
off_t osize;
FILE *fp;