[Git][NTPsec/ntpsec][master] 3 commits: Add missing initializers.

Gary E. Miller gitlab at mg.gitlab.com
Thu Sep 22 23:09:38 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
5dbd9af0 by Hal Murray at 2016-09-22T15:47:46-07:00
Add missing initializers.

Signed-off-by: Gary E. Miller <gem at rellim.com>

- - - - -
85ea800d by Hal Murray at 2016-09-22T15:57:52-07:00
Improve tests for NTP_MINPOLL and NTP_MAXPOLL

When NTP_MINPOLL goes to 0, the < NTP_MINPOLL will go away.

Signed-off-by: Gary E. Miller <gem at rellim.com>

- - - - -
779b86b0 by Hal Murray at 2016-09-22T16:07:33-07:00
Some more explicit initalization.

Signed-off-by: Gary E. Miller <gem at rellim.com>

- - - - -


1 changed file:

- ntpd/ntp_config.c


Changes:

=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -75,9 +75,9 @@
 
 
 /* list of servers from command line for config_peers() */
-int	cmdline_server_count;
+int	cmdline_server_count = 0;
 char **	cmdline_servers;
-bool	force_synchronous_dns;
+bool	force_synchronous_dns = false;
 
 /*
  * FIXME: ugly globals, only created to avoid wiring in option-parsing cruft.
@@ -625,6 +625,8 @@ create_peer_node(
 	/* Initialize node values to default */
 
 	my_node->ctl.version = NTP_VERSION;
+	my_node->ctl.minpoll = NTP_MINDPOLL;
+	my_node->ctl.maxpoll = NTP_MAXDPOLL;
 
 	/* Now set the node to the read values */
 	my_node->host_mode = hmode;
@@ -686,13 +688,18 @@ create_peer_node(
 			break;
 
 		case T_Minpoll:
-			if (option->value.i < NTP_MINPOLL ||
-			    option->value.i > UCHAR_MAX) {
+			if (option->value.i < NTP_MINPOLL ) {
 				msyslog(LOG_INFO,
-					"minpoll: provided value (%d) is out of range [%d-%d])",
+					"minpoll: provided value (%d) is too small [%d-%d])",
 					option->value.i, NTP_MINPOLL,
-					UCHAR_MAX);
+					NTP_MAXPOLL);
 				my_node->ctl.minpoll = NTP_MINPOLL;
+			} else if (option->value.i > NTP_MAXPOLL) {
+				msyslog(LOG_INFO,
+					"minpoll: provided value (%d) is too large [%d-%d])",
+					option->value.i, NTP_MINPOLL,
+					NTP_MAXPOLL);
+				my_node->ctl.minpoll = NTP_MAXPOLL;
 			} else {
 				my_node->ctl.minpoll =
 					(uint8_t)option->value.u;
@@ -700,12 +707,18 @@ create_peer_node(
 			break;
 
 		case T_Maxpoll:
-			if (option->value.i < 0 ||
-			    option->value.i > NTP_MAXPOLL) {
-				msyslog(LOG_INFO,
-					"maxpoll: provided value (%d) is out of range [0-%d])",
-					option->value.i, NTP_MAXPOLL);
-				my_node->ctl.maxpoll = NTP_MAXPOLL;
+			if (option->value.i < NTP_MINPOLL ) {
+			    msyslog(LOG_INFO,
+				"maxpoll: value (%d) is too small [%d-%d])",
+				option->value.i, NTP_MINPOLL,
+				NTP_MAXPOLL);
+			    my_node->ctl.maxpoll = NTP_MINPOLL;
+			} else if ( option->value.i > NTP_MAXPOLL) {
+			    msyslog(LOG_INFO,
+				"maxpoll: value (%d) is too large [%s-%d])",
+				option->value.i, NTP_MINPOLL,
+				NTP_MAXPOLL);
+			    my_node->ctl.maxpoll = NTP_MAXPOLL;
 			} else {
 				my_node->ctl.maxpoll =
 					(uint8_t)option->value.u;
@@ -2828,8 +2841,12 @@ config_peers(
 			ctx->family = AF_UNSPEC;
 			ctx->host_mode = T_Server;
 			ctx->hmode = MODE_CLIENT;
+			ctx->ctl.flags   = FLAG_IBURST;
+			ctx->ctl.maxpoll = NTP_MAXDPOLL;
+			ctx->ctl.minpoll = NTP_MINDPOLL;
+			ctx->ctl.peerkey = 0;
+			ctx->ctl.ttl     = 0;
 			ctx->ctl.version = NTP_VERSION;
-			ctx->ctl.flags = FLAG_IBURST;
 
 			ZERO(hints);
 			hints.ai_family = (u_short)ctx->family;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/4f4bbec636cc5a2aa898bbfaccd7a2272605308f...779b86b0a0e38ccf5e7e131a6129d818a0e160df
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160922/cac1469f/attachment.html>


More information about the vc mailing list