-/* $OpenBSD: config.c,v 1.22 2015/01/10 13:47:05 tedu Exp $ */
+/* $OpenBSD: config.c,v 1.23 2015/01/13 02:28:56 bcook Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
return (h);
}
+void
+host_dns_free(struct ntp_addr *hn)
+{
+ struct ntp_addr *h = hn, *tmp;
+ while (h) {
+ tmp = h;
+ h = h->next;
+ free(tmp);
+ }
+}
+
int
host_dns(const char *s, struct ntp_addr **hn)
{
-/* $OpenBSD: ntp_dns.c,v 1.6 2015/01/09 07:35:37 deraadt Exp $ */
+/* $OpenBSD: ntp_dns.c,v 1.7 2015/01/13 02:28:56 bcook Exp $ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
buf = imsg_create(ibuf_dns, IMSG_HOST_DNS,
imsg.hdr.peerid, 0,
cnt * sizeof(struct sockaddr_storage));
- if (buf == NULL)
- break;
- if (cnt > 0)
- for (h = hn; h != NULL; h = h->next)
- imsg_add(buf, &h->ss, sizeof(h->ss));
-
- imsg_close(ibuf_dns, buf);
+ if (cnt > 0) {
+ if (buf) {
+ for (h = hn; h != NULL; h = h->next)
+ if (imsg_add(buf, &h->ss,
+ sizeof(h->ss)) == -1) {
+ buf = NULL;
+ break;
+ }
+ if (buf)
+ imsg_close(ibuf_dns, buf);
+ }
+ host_dns_free(hn);
+ hn = NULL;
+ }
break;
default:
break;
-/* $OpenBSD: ntpd.c,v 1.83 2015/01/09 07:35:37 deraadt Exp $ */
+/* $OpenBSD: ntpd.c,v 1.84 2015/01/13 02:28:56 bcook Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
buf = imsg_create(ibuf, IMSG_HOST_DNS,
imsg.hdr.peerid, 0,
cnt * sizeof(struct sockaddr_storage));
- if (buf == NULL)
- break;
- if (cnt > 0)
- for (h = hn; h != NULL; h = h->next)
- imsg_add(buf, &h->ss, sizeof(h->ss));
-
- imsg_close(ibuf, buf);
+ if (cnt > 0) {
+ if (buf) {
+ for (h = hn; h != NULL; h = h->next)
+ if (imsg_add(buf, &h->ss,
+ sizeof(h->ss)) == -1) {
+ buf = NULL;
+ break;
+ }
+ if (buf)
+ imsg_close(ibuf, buf);
+ }
+ host_dns_free(hn);
+ hn = NULL;
+ }
break;
default:
break;
-/* $OpenBSD: ntpd.h,v 1.116 2015/01/10 13:47:05 tedu Exp $ */
+/* $OpenBSD: ntpd.h,v 1.117 2015/01/13 02:28:56 bcook Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
/* config.c */
void host(const char *, struct ntp_addr **);
int host_dns(const char *, struct ntp_addr **);
+void host_dns_free(struct ntp_addr *);
struct ntp_peer *new_peer(void);
struct ntp_conf_sensor *new_sensor(char *);