From e284a262942eb8c69d7862cb61bf4542baec6032 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Apr 2005 07:40:23 +0000 Subject: r6338: ADS style GETDC response now works well enough that WinXP can join Samba4 without Samba3 nmbd (This used to be commit f4d07d7d3b6973b503d8c98f177471dd6cebfa92) --- source4/libcli/nbt/nbtname.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source4/libcli/nbt') diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c index f7d19d11cf..5f344d9c6d 100644 --- a/source4/libcli/nbt/nbtname.c +++ b/source4/libcli/nbt/nbtname.c @@ -144,6 +144,11 @@ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s) return NT_STATUS_OK; } + if (s == NULL || *s == 0) { + return ndr_push_bytes(ndr, "", 1); + } + + fullname = talloc_strdup(ndr, ""); NT_STATUS_HAVE_NO_MEMORY(fullname); @@ -162,11 +167,14 @@ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s) so, we can use a NBT name pointer. This allows us to fit longer names into the packet */ fulllen = strlen(fullname)+1; - for (i=0;i + fulllen < ndr->offset;i++) { + for (i=0;i + fulllen <= ndr->offset;i++) { if (ndr->data[i] == fullname[0] && memcmp(fullname, &ndr->data[i], fulllen) == 0) { + uint8_t b[2]; talloc_free(fullname); - return ndr_push_uint16(ndr, NDR_SCALARS, 0xC000 | i); + b[0] = 0xC0 | (i>>8); + b[1] = (i&0xFF); + return ndr_push_bytes(ndr, b, 2); } } -- cgit