summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/nbt/nbtname.c10
-rw-r--r--source4/libcli/resolve/nbtlist.c7
-rw-r--r--source4/torture/nbt/wins.c40
-rw-r--r--source4/utils/nmblookup.c8
4 files changed, 59 insertions, 6 deletions
diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c
index 1904b33a9b..0d2840e0b5 100644
--- a/source4/libcli/nbt/nbtname.c
+++ b/source4/libcli/nbt/nbtname.c
@@ -114,7 +114,7 @@ static NTSTATUS decompress_name(char *name, enum nbt_name_type *type)
compress a name component
*/
static uint8_t *compress_name(TALLOC_CTX *mem_ctx,
- uint8_t *name, enum nbt_name_type type)
+ const uint8_t *name, enum nbt_name_type type)
{
uint8_t *cname;
int i;
@@ -211,7 +211,7 @@ NTSTATUS ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, struct nbt_name
{
uint_t num_components;
uint8_t *components[MAX_COMPONENTS];
- char *dname, *dscope=NULL, *p;
+ char *dscope=NULL, *p;
uint8_t *cname;
int i;
@@ -219,14 +219,12 @@ NTSTATUS ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, struct nbt_name
return NT_STATUS_OK;
}
- dname = strupper_talloc(ndr, r->name);
- NT_STATUS_HAVE_NO_MEMORY(dname);
if (r->scope) {
- dscope = strupper_talloc(ndr, r->scope);
+ dscope = talloc_strdup(ndr, r->scope);
NT_STATUS_HAVE_NO_MEMORY(dscope);
}
- cname = compress_name(ndr, dname, r->type);
+ cname = compress_name(ndr, r->name, r->type);
NT_STATUS_HAVE_NO_MEMORY(cname);
/* form the base components */
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index 5a9e31e09d..89e9a63748 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -101,6 +101,13 @@ struct composite_context *resolve_name_nbtlist_send(struct nbt_name *name,
status = nbt_name_dup(state, name, &state->name);
if (!NT_STATUS_IS_OK(status)) goto failed;
+ state->name.name = strupper_talloc(state, state->name.name);
+ if (state->name.name == NULL) goto failed;
+ if (state->name.scope) {
+ state->name.scope = strupper_talloc(state, state->name.scope);
+ if (state->name.scope == NULL) goto failed;
+ }
+
state->nbtsock = nbt_name_socket_init(state, event_ctx);
if (state->nbtsock == NULL) goto failed;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index fdd5a1094d..27b50dd204 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -114,6 +114,42 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address,
CHECK_VALUE(query.out.num_addrs, 1);
CHECK_STRING(query.out.reply_addrs[0], myaddress);
+
+ query.in.name.name = strupper_talloc(mem_ctx, name->name);
+ if (query.in.name.name &&
+ strcmp(query.in.name.name, name->name) != 0) {
+ printf("check case sensitivity\n");
+ status = nbt_name_query(nbtsock, mem_ctx, &query);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ printf("No response from %s for name query\n", address);
+ return False;
+ }
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ printf("Bad response from %s for name query - %s\n",
+ address, nt_errstr(status));
+ return False;
+ }
+ }
+
+ query.in.name = *name;
+ if (name->scope) {
+ query.in.name.scope = strupper_talloc(mem_ctx, name->scope);
+ }
+ if (query.in.name.scope &&
+ strcmp(query.in.name.scope, name->scope) != 0) {
+ printf("check case sensitivity on scope\n");
+ status = nbt_name_query(nbtsock, mem_ctx, &query);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ printf("No response from %s for name query\n", address);
+ return False;
+ }
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ printf("Bad response from %s for name query - %s\n",
+ address, nt_errstr(status));
+ return False;
+ }
+ }
+
printf("refresh the name\n");
refresh.in.name = *name;
refresh.in.wins_servers = str_list_make(mem_ctx, address, NULL);
@@ -176,6 +212,7 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address,
printf("query the name to make sure its gone\n");
+ query.in.name = *name;
status = nbt_name_query(nbtsock, mem_ctx, &query);
if (NT_STATUS_IS_OK(status)) {
printf("ERROR: Name query success after release\n");
@@ -222,6 +259,9 @@ static BOOL nbt_test_wins(TALLOC_CTX *mem_ctx, const char *address)
name.name = talloc_asprintf(mem_ctx, ".");
ret &= nbt_test_wins_name(mem_ctx, address, &name);
+ name.name = talloc_asprintf(mem_ctx, "%5u-\377\200\300FOO", r);
+ ret &= nbt_test_wins_name(mem_ctx, address, &name);
+
return ret;
}
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c
index 5e8b59edc8..857d03fe19 100644
--- a/source4/utils/nmblookup.c
+++ b/source4/utils/nmblookup.c
@@ -38,6 +38,7 @@ static struct {
BOOL node_status;
BOOL root_port;
BOOL lookup_by_ip;
+ BOOL case_sensitive;
} options;
/*
@@ -178,6 +179,10 @@ static void process_one(const char *name)
char *node_name, *p;
struct nbt_name_socket *nbtsock;
NTSTATUS status;
+
+ if (!options.case_sensitive) {
+ name = strupper_talloc(tmp_ctx, name);
+ }
if (options.find_master) {
node_type = NBT_NAME_MASTER;
@@ -259,6 +264,9 @@ int main(int argc,char *argv[])
{ "lookup-by-ip", 'A', POPT_ARG_VAL, &options.lookup_by_ip,
True, "Do a node status on <name> as an IP Address" },
+ { "case-sensitive", 0, POPT_ARG_VAL, &options.case_sensitive,
+ True, "Don't uppercase the name before sending" },
+
POPT_COMMON_SAMBA
{ 0, 0, 0, 0 }
};