summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2015-01-30 14:37:06 +0100
committerJeremy Allison <jra@samba.org>2015-02-24 01:01:10 +0100
commit84d4270c8e4ec18e9f83722d6df1a07f70acaade (patch)
treedf746b64b7d84795bd7a445ccd8d1013fc9df814
parenta782ae1da463433b6f5199acd0d093583780dd20 (diff)
downloadsamba-84d4270c8e4ec18e9f83722d6df1a07f70acaade.tar.gz
samba-84d4270c8e4ec18e9f83722d6df1a07f70acaade.tar.xz
samba-84d4270c8e4ec18e9f83722d6df1a07f70acaade.zip
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
-rw-r--r--libcli/nbt/tools/nmblookup.c13
-rw-r--r--source3/utils/nmblookup.c9
2 files changed, 22 insertions, 0 deletions
diff --git a/libcli/nbt/tools/nmblookup.c b/libcli/nbt/tools/nmblookup.c
index 9b875b08c4..afb81c745c 100644
--- a/libcli/nbt/tools/nmblookup.c
+++ b/libcli/nbt/tools/nmblookup.c
@@ -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) {
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index 78548e9d68..a119b3eabe 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -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 );