mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
nmblookup: Warn user if netbios name is too long.
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Feb 24 01:01:10 CET 2015 on sn-devel-104
This commit is contained in:
parent
a782ae1da4
commit
84d4270c8e
@ -32,6 +32,10 @@
|
||||
#include "../libcli/nbt/libnbt.h"
|
||||
#include "param/param.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_NETBIOSNAME_LEN 16
|
||||
|
||||
/* command line options */
|
||||
static struct {
|
||||
const char *broadcast_address;
|
||||
@ -190,6 +194,7 @@ static bool process_one(struct loadparm_context *lp_ctx, struct tevent_context *
|
||||
struct socket_address *all_zero_addr;
|
||||
struct nbt_name_socket *nbtsock;
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
size_t nbt_len;
|
||||
bool ret = true;
|
||||
|
||||
if (!options.case_sensitive) {
|
||||
@ -212,6 +217,14 @@ static bool process_one(struct loadparm_context *lp_ctx, struct tevent_context *
|
||||
node_name = talloc_strdup(tmp_ctx, name);
|
||||
}
|
||||
|
||||
nbt_len = strlen(node_name);
|
||||
if (nbt_len > MAX_NETBIOSNAME_LEN - 1) {
|
||||
printf("The specified netbios name [%s] is too long.\n",
|
||||
node_name);
|
||||
talloc_free(tmp_ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
nbtsock = nbt_name_socket_init(tmp_ctx, ev);
|
||||
|
||||
if (options.root_port) {
|
||||
|
@ -320,6 +320,7 @@ int main(int argc, const char *argv[])
|
||||
while(poptPeekArg(pc)) {
|
||||
char *p;
|
||||
struct in_addr ip;
|
||||
size_t nbt_len;
|
||||
|
||||
fstrcpy(lookup,poptGetArg(pc));
|
||||
|
||||
@ -349,6 +350,14 @@ int main(int argc, const char *argv[])
|
||||
sscanf(++p,"%x",&lookup_type);
|
||||
}
|
||||
|
||||
nbt_len = strlen(lookup);
|
||||
if (nbt_len > MAX_NETBIOSNAME_LEN - 1) {
|
||||
d_printf("The specified netbios name [%s] is too long!\n",
|
||||
lookup);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!query_one(lookup, lookup_type)) {
|
||||
rc = 1;
|
||||
d_printf( "name_query failed to find name %s", lookup );
|
||||
|
Loading…
x
Reference in New Issue
Block a user