1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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>
This commit is contained in:
Andreas Schneider 2015-01-13 17:04:26 +01:00 committed by Michael Adam
parent a0a254f742
commit 45829800eb

View File

@ -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;