|
From c33a7dbd5827d8cf3e81193ea128d9b29a596c4c Mon Sep 17 00:00:00 2001
|
|
From: Brent Cook <busterb@gmail.com>
|
|
Date: Mon, 19 Jan 2015 04:37:59 -0600
|
|
Subject: [PATCH 13/13] log context of all fatal allocations
|
|
|
|
---
|
|
src/usr.sbin/ntpd/config.c | 8 ++++----
|
|
src/usr.sbin/ntpd/ntp.c | 8 ++++----
|
|
src/usr.sbin/ntpd/ntp_dns.c | 2 +-
|
|
src/usr.sbin/ntpd/ntpd.c | 6 +++---
|
|
src/usr.sbin/ntpd/parse.y | 6 +++---
|
|
5 files changed, 15 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/src/usr.sbin/ntpd/config.c b/src/usr.sbin/ntpd/config.c
|
|
index 9777110..56b50d2 100644
|
|
--- a/src/usr.sbin/ntpd/config.c
|
|
+++ b/src/usr.sbin/ntpd/config.c
|
|
@@ -41,7 +41,7 @@ host(const char *s, struct ntp_addr **hn)
|
|
|
|
if (!strcmp(s, "*"))
|
|
if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ntp_addr calloc");
|
|
|
|
/* IPv4 address? */
|
|
if (h == NULL)
|
|
@@ -69,7 +69,7 @@ host_v4(const char *s)
|
|
return (NULL);
|
|
|
|
if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ntp_addr calloc");
|
|
sa_in = (struct sockaddr_in *)&h->ss;
|
|
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
|
|
sa_in->sin_len = sizeof(struct sockaddr_in);
|
|
@@ -93,7 +93,7 @@ host_v6(const char *s)
|
|
hints.ai_flags = AI_NUMERICHOST;
|
|
if (getaddrinfo(s, "0", &hints, &res) == 0) {
|
|
if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ntp_addr calloc");
|
|
sa_in6 = (struct sockaddr_in6 *)&h->ss;
|
|
#ifdef SIN6_LEN
|
|
sa_in6->sin6_len = sizeof(struct sockaddr_in6);
|
|
@@ -154,7 +154,7 @@ host_dns(const char *s, struct ntp_addr **hn)
|
|
res->ai_family != AF_INET6)
|
|
continue;
|
|
if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ntp_addr calloc");
|
|
h->ss.ss_family = res->ai_family;
|
|
if (res->ai_family == AF_INET) {
|
|
sa_in = (struct sockaddr_in *)&h->ss;
|
|
diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c
|
|
index c8f095e..7db98f6 100644
|
|
--- a/src/usr.sbin/ntpd/ntp.c
|
|
+++ b/src/usr.sbin/ntpd/ntp.c
|
|
@@ -112,7 +112,7 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
|
|
fatal("getservbyname");
|
|
|
|
if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
|
|
- fatal(NULL);
|
|
+ fatal("open /dev/null");
|
|
hotplugfd = sensor_hotplugfd();
|
|
|
|
close(pipe_prnt[0]);
|
|
@@ -166,10 +166,10 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
|
|
signal(SIGCHLD, SIG_DFL);
|
|
|
|
if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ibuf_main malloc");
|
|
imsg_init(ibuf_main, pipe_prnt[1]);
|
|
if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ibuf_dns malloc");
|
|
imsg_init(ibuf_dns, pipe_dns[0]);
|
|
|
|
TAILQ_FOREACH(p, &conf->ntp_peers, entry)
|
|
@@ -508,7 +508,7 @@ ntp_dispatch_imsg_dns(void)
|
|
while (dlen >= sizeof(struct sockaddr_storage)) {
|
|
if ((h = calloc(1, sizeof(struct ntp_addr))) ==
|
|
NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ntp_addr calloc");
|
|
memcpy(&h->ss, p, sizeof(h->ss));
|
|
p += sizeof(h->ss);
|
|
dlen -= sizeof(h->ss);
|
|
diff --git a/src/usr.sbin/ntpd/ntp_dns.c b/src/usr.sbin/ntpd/ntp_dns.c
|
|
index 7d0236f..6abe3a4 100644
|
|
--- a/src/usr.sbin/ntpd/ntp_dns.c
|
|
+++ b/src/usr.sbin/ntpd/ntp_dns.c
|
|
@@ -87,7 +87,7 @@ ntp_dns(int pipe_ntp[2], struct ntpd_conf *nconf, struct passwd *pw)
|
|
signal(SIGHUP, sighdlr_dns);
|
|
|
|
if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("imsgbuf malloc");
|
|
imsg_init(ibuf_dns, pipe_ntp[1]);
|
|
|
|
while (quit_dns == 0) {
|
|
diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
|
|
index ea8cf70..65503d9 100644
|
|
--- a/src/usr.sbin/ntpd/ntpd.c
|
|
+++ b/src/usr.sbin/ntpd/ntpd.c
|
|
@@ -235,7 +235,7 @@ main(int argc, char *argv[])
|
|
close(pipe_chld[1]);
|
|
|
|
if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("imsgbuf malloc");
|
|
imsg_init(ibuf, pipe_chld[0]);
|
|
|
|
while (quit == 0) {
|
|
@@ -619,7 +619,7 @@ ctl_main(int argc, char *argv[])
|
|
break;
|
|
}
|
|
}
|
|
- if (action == -1)
|
|
+ if (action == -1)
|
|
usage();
|
|
/* NOTREACHED */
|
|
|
|
@@ -635,7 +635,7 @@ ctl_main(int argc, char *argv[])
|
|
err(1, "connect: %s", sockname);
|
|
|
|
if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL)
|
|
- err(1, NULL);
|
|
+ err(1, "malloc: imsgbuf");
|
|
imsg_init(ibuf_ctl, fd);
|
|
|
|
switch (action) {
|
|
diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y
|
|
index 42a49f7..285fae8 100644
|
|
--- a/src/usr.sbin/ntpd/parse.y
|
|
+++ b/src/usr.sbin/ntpd/parse.y
|
|
@@ -161,7 +161,7 @@ main : LISTEN ON address listen_opts {
|
|
p->addr_head.pool = 1;
|
|
p->addr_head.name = strdup($2->name);
|
|
if (p->addr_head.name == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("servers strdup");
|
|
if (p->addr != NULL)
|
|
p->state = STATE_DNS_DONE;
|
|
if (!(p->rtable > 0 && p->addr))
|
|
@@ -200,7 +200,7 @@ main : LISTEN ON address listen_opts {
|
|
p->addr_head.pool = 0;
|
|
p->addr_head.name = strdup($2->name);
|
|
if (p->addr_head.name == NULL)
|
|
- fatal(NULL);
|
|
+ fatal("server strdup");
|
|
if (p->addr != NULL)
|
|
p->state = STATE_DNS_DONE;
|
|
if (!(p->rtable > 0 && p->addr))
|
|
@@ -224,7 +224,7 @@ main : LISTEN ON address listen_opts {
|
|
address : STRING {
|
|
if (($$ = calloc(1, sizeof(struct ntp_addr_wrap))) ==
|
|
NULL)
|
|
- fatal(NULL);
|
|
+ fatal("ntp_addr_wrap calloc");
|
|
host($1, &$$->a);
|
|
$$->name = $1;
|
|
}
|
|
--
|
|
1.9.1
|
|
|