mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-22 16:44:32 +01:00
Use strtol to parse the <%d> tags in printline() and printsys().
Sort local variables declarations in these functions. Submitted by: bde
This commit is contained in:
parent
387c10289f
commit
9323dbdb0a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125271
@ -645,18 +645,21 @@ usage(void)
|
|||||||
static void
|
static void
|
||||||
printline(const char *hname, char *msg)
|
printline(const char *hname, char *msg)
|
||||||
{
|
{
|
||||||
|
char *p, *q;
|
||||||
|
long n;
|
||||||
int c, pri;
|
int c, pri;
|
||||||
char *p, *q, line[MAXLINE + 1];
|
char line[MAXLINE + 1];
|
||||||
|
|
||||||
/* test for special codes */
|
/* test for special codes */
|
||||||
pri = DEFUPRI;
|
|
||||||
p = msg;
|
p = msg;
|
||||||
|
pri = DEFUPRI;
|
||||||
if (*p == '<') {
|
if (*p == '<') {
|
||||||
pri = 0;
|
errno = 0;
|
||||||
while (isdigit(*++p))
|
n = strtol(p + 1, &q, 10);
|
||||||
pri = 10 * pri + (*p - '0');
|
if (*q == '>' && n >= 0 && n < INT_MAX && errno == 0) {
|
||||||
if (*p == '>')
|
p = q + 1;
|
||||||
++p;
|
pri = n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
|
if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
|
||||||
pri = DEFUPRI;
|
pri = DEFUPRI;
|
||||||
@ -736,24 +739,21 @@ readklog(void)
|
|||||||
static void
|
static void
|
||||||
printsys(char *msg)
|
printsys(char *msg)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p, *q;
|
||||||
int flags, isprintf, n, pri;
|
long n;
|
||||||
|
int flags, isprintf, pri;
|
||||||
|
|
||||||
flags = ISKERNEL | SYNC_FILE | ADDDATE; /* fsync after write */
|
flags = ISKERNEL | SYNC_FILE | ADDDATE; /* fsync after write */
|
||||||
pri = DEFSPRI;
|
|
||||||
p = msg;
|
p = msg;
|
||||||
|
pri = DEFSPRI;
|
||||||
isprintf = 1;
|
isprintf = 1;
|
||||||
if (*p == '<') {
|
if (*p == '<') {
|
||||||
n = 0;
|
errno = 0;
|
||||||
while (isdigit(*++p))
|
n = strtol(p + 1, &q, 10);
|
||||||
n = 10 * n + (*p - '0');
|
if (*q == '>' && n >= 0 && n < INT_MAX && errno == 0) {
|
||||||
if (*p == '>') {
|
p = q + 1;
|
||||||
++p;
|
|
||||||
pri = n;
|
pri = n;
|
||||||
isprintf = 0;
|
isprintf = 0;
|
||||||
} else {
|
|
||||||
/* It wasn't actually a syslog message. */
|
|
||||||
p = msg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user