[Git][NTPsec/ntpsec][master] 2 commits: Rationalize a configuration-block copy.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Sep 5 13:15:43 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
5d6d6217 by Eric S. Raymond at 2017-09-05T08:46:52-04:00
Rationalize a configuration-block copy.
- - - - -
c7f1ede7 by Eric S. Raymond at 2017-09-05T09:14:59-04:00
Remove an obfuscatory macro.
- - - - -
7 changed files:
- include/ntp_malloc.h
- libntp/emalloc.c
- libntp/netof.c
- ntpd/ntp_io.c
- ntpd/ntp_monitor.c
- ntpd/ntp_peer.c
- ntpd/ntp_restrict.c
Changes:
=====================================
include/ntp_malloc.h
=====================================
--- a/include/ntp_malloc.h
+++ b/include/ntp_malloc.h
@@ -39,8 +39,6 @@ void * alloca(size_t);
#include <strings.h>
-#define zero_mem(p, s) memset(p, 0, s)
-
-#define ZERO(var) zero_mem(&(var), sizeof(var))
+#define ZERO(var) memset(&(var), '\0', sizeof(var))
#endif /* GUARD_NTP_MALLOC_H */
=====================================
libntp/emalloc.c
=====================================
--- a/libntp/emalloc.c
+++ b/libntp/emalloc.c
@@ -55,7 +55,7 @@ ereallocz(
}
if (zero_init && newsz > priorsz)
- zero_mem(mem + priorsz, newsz - priorsz);
+ memset(mem + priorsz, '\0', newsz - priorsz);
return mem;
}
=====================================
libntp/netof.c
=====================================
--- a/libntp/netof.c
+++ b/libntp/netof.c
@@ -32,7 +32,7 @@ netof6(
if (IS_IPV6(netaddr))
/* assume the typical /64 subnet size */
- zero_mem(&NSRCADR6(netaddr)[8], 8);
+ memset(&NSRCADR6(netaddr)[8], '\0', 8);
#ifdef DEBUG
else {
msyslog(LOG_ERR, "ERR: Not IPv6, AF %d", AF(netaddr));
=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -2319,7 +2319,7 @@ read_network_packet(
iovec.iov_base = &rb->recv_space;
iovec.iov_len = sizeof(rb->recv_space);
- zero_mem(&msghdr, sizeof(msghdr));
+ memset(&msghdr, '\0', sizeof(msghdr));
msghdr.msg_name = &rb->recv_srcadr;
msghdr.msg_namelen = fromlen;
msghdr.msg_iov = &iovec;
=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -259,7 +259,7 @@ mon_stop(
/* empty the MRU list and hash table. */
mru_entries = 0;
INIT_DLIST(mon_mru_list, mru);
- zero_mem(mon_hash, sizeof(*mon_hash) * MON_HASH_SIZE);
+ memset(mon_hash, '\0', sizeof(*mon_hash) * MON_HASH_SIZE);
}
=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -699,22 +699,31 @@ newpeer(
if (hostname != NULL)
peer->hostname = estrdup(hostname);
peer->hmode = hmode;
+
+ /*
+ * Copy in the peer configuration block.
+ */
peer->cfg.version = ctl->version;
peer->cfg.flags = ctl->flags;
+ peer->cfg.minpoll = ctl->minpoll;
+ peer->cfg.maxpoll = ctl->maxpoll;
+ peer->cfg.ttl = ctl->ttl;
+ peer->cfg.peerkey = ctl->peerkey;
+
peer->cast_flags = cast_flags;
set_peerdstadr(peer,
select_peerinterface(peer, srcadr, dstadr));
- if (NTP_MAXPOLL_UNK == ctl->maxpoll)
+ if (NTP_MAXPOLL_UNK == peer->cfg.maxpoll)
/* not set yet, set to default */
- ctl->maxpoll = NTP_MAXDPOLL;
+ peer->cfg.maxpoll = NTP_MAXDPOLL;
/*
* minpoll is clamped not greater than NTP_MAXPOLL
* maxpoll is clamped not less than NTP_MINPOLL
* minpoll is clamped not greater than maxpoll.
*/
- peer->cfg.minpoll = min(ctl->minpoll, NTP_MAXPOLL);
- peer->cfg.maxpoll = max(ctl->maxpoll, NTP_MINPOLL);
+ peer->cfg.minpoll = min(peer->cfg.minpoll, NTP_MAXPOLL);
+ peer->cfg.maxpoll = max(peer->cfg.maxpoll, NTP_MINPOLL);
if (peer->cfg.minpoll > peer->cfg.maxpoll)
peer->cfg.minpoll = peer->cfg.maxpoll;
@@ -732,8 +741,6 @@ newpeer(
if ((MDF_BCAST & cast_flags) && peer->dstadr != NULL)
enable_broadcast(peer->dstadr, srcadr);
- peer->cfg.ttl = ctl->ttl;
- peer->cfg.peerkey = ctl->peerkey;
peer->precision = sys_precision;
peer->hpoll = peer->cfg.minpoll;
if (cast_flags & MDF_POOL)
=====================================
ntpd/ntp_restrict.c
=====================================
--- a/ntpd/ntp_restrict.c
+++ b/ntpd/ntp_restrict.c
@@ -224,10 +224,10 @@ free_res(
INSIST(unlinked == res);
if (v6) {
- zero_mem(res, V6_SIZEOF_RESTRICT_U);
+ memset(res, '\0', V6_SIZEOF_RESTRICT_U);
plisthead = &resfree6;
} else {
- zero_mem(res, V4_SIZEOF_RESTRICT_U);
+ memset(res, '\0', V4_SIZEOF_RESTRICT_U);
plisthead = &resfree4;
}
LINK_SLIST(*plisthead, res, link);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/2bd5e61d66f8d0e274b4b52df2eac880f22efbfb...c7f1ede75a3fd321ef0e8c84e128cad71df033a4
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/2bd5e61d66f8d0e274b4b52df2eac880f22efbfb...c7f1ede75a3fd321ef0e8c84e128cad71df033a4
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170905/8af727dd/attachment.html>
More information about the vc
mailing list