[PATCH 1/2] NTPD: Check if a peer was defined on the command line.
Jean-Christophe DUBOIS
jcd at tribudubois.net
Sun Oct 3 16:24:48 UTC 2010
Check if a peer was defined on the ntpd command line.
Without a peer defined, we just abort as the ntpd program
will not do anything usefull.
Signed-off-by: Jean-Christophe DUBOIS <jcd at tribudubois.net>
---
networking/ntpd.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 14c3a5f..0f0772b 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -1940,6 +1940,14 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
ntp_init(argv);
+ /* it is useless to continue if no peer is defined */
+ /* if in server mode, we will never sync */
+ /* if in client mode, we will never sync */
+ if (G.peer_cnt == 0) {
+ bb_error_msg("no peer defined");
+ return -EINVAL;
+ }
+
/* If ENABLE_FEATURE_NTPD_SERVER, + 1 for listen_fd: */
cnt = G.peer_cnt + ENABLE_FEATURE_NTPD_SERVER;
idx2peer = xzalloc(sizeof(idx2peer[0]) * cnt);
--
1.7.0.4
More information about the busybox
mailing list