summaryrefslogtreecommitdiffstats
path: root/libcli
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 /libcli
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
Diffstat (limited to 'libcli')
-rw-r--r--libcli/nbt/tools/nmblookup.c13
1 files changed, 13 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) {