summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2015-01-13 17:04:26 +0100
committerMichael Adam <obnox@samba.org>2015-01-19 06:48:05 +0100
commit45829800eb3f3a8aeccfe7c1114dcf9df60371d5 (patch)
tree54bee344d75b417d7da62c9ac459cc640f3d5aa7
parenta0a254f74234bed6c9a0c71a5bda8254fa6f633f (diff)
downloadsamba-45829800eb3f3a8aeccfe7c1114dcf9df60371d5.tar.gz
samba-45829800eb3f3a8aeccfe7c1114dcf9df60371d5.tar.xz
samba-45829800eb3f3a8aeccfe7c1114dcf9df60371d5.zip
utils: Fix 'net time' segfault.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11058 This is part two of the bugfix. Make sure we pass the IP we found to cli_servertime(). Hence we always pass at least one of name or IP. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source3/utils/net_time.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 56ce8f71ad..595d903c0b 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -226,16 +226,23 @@ int net_time(struct net_context *c, int argc, const char **argv)
return 0;
}
- if (!c->opt_host && !c->opt_have_ip &&
- !find_master_ip(c->opt_target_workgroup, &c->opt_dest_ip)) {
- d_fprintf(stderr, _("Could not locate a time server. Try "
- "specifying a target host.\n"));
- net_time_usage(c, argc,argv);
- return -1;
+ if (c->opt_host == NULL && !c->opt_have_ip) {
+ bool ok;
+
+ ok = find_master_ip(c->opt_target_workgroup, &c->opt_dest_ip);
+ if (!ok) {
+ d_fprintf(stderr,
+ _("Could not locate a time server. "
+ "Try specifying a target host.\n"));
+ net_time_usage(c, argc, argv);
+ return -1;
+ }
+ c->opt_have_ip = true;
}
/* default - print the time */
- t = cli_servertime(c->opt_host, c->opt_have_ip? &c->opt_dest_ip : NULL,
+ t = cli_servertime(c->opt_host,
+ c->opt_have_ip? &c->opt_dest_ip : NULL,
NULL);
if (t == 0) return -1;