summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/dgram/libdgram.h1
-rw-r--r--source4/libcli/dgram/mailslot.c20
-rw-r--r--source4/libcli/dgram/netlogon.c8
-rw-r--r--source4/libcli/dgram/ntlogon.c8
4 files changed, 28 insertions, 9 deletions
diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h
index af278d2ab6..b8ca9e2fe5 100644
--- a/source4/libcli/dgram/libdgram.h
+++ b/source4/libcli/dgram/libdgram.h
@@ -109,6 +109,7 @@ struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgms
const char *mailslot_name,
dgram_mailslot_handler_t handler,
void *private);
+DATA_BLOB dgram_mailslot_data(struct nbt_dgram_packet *dgram);
NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index ca9a66a729..d7c0870ded 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -167,7 +167,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
msg = &packet.data.msg;
/* this length calculation is very crude - it should be based on gensize
calls */
- msg->length = 138 + strlen(mailslot_name) + request->length;
+ msg->length = 138 + strlen(mailslot_name) + request->length;
msg->offset = 0;
msg->source_name = *src_name;
@@ -194,3 +194,21 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
return status;
}
+
+/*
+ return the mailslot data portion from a mailslot packet
+*/
+DATA_BLOB dgram_mailslot_data(struct nbt_dgram_packet *dgram)
+{
+ struct smb_trans_body *trans = &dgram->data.msg.body.smb.body.trans;
+ DATA_BLOB ret = trans->data;
+ int pad = trans->data_offset - (70 + strlen(trans->mailslot_name));
+
+ if (pad < 0 || pad > ret.length) {
+ DEBUG(2,("Badly formatted data in mailslot - pad = %d\n", pad));
+ return data_blob(NULL, 0);
+ }
+ ret.data += pad;
+ ret.length -= pad;
+ return ret;
+}
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index a030ca73c2..208117845b 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -101,16 +101,16 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *dgram,
struct nbt_netlogon_packet *netlogon)
{
- DATA_BLOB *data = &dgram->data.msg.body.smb.body.trans.data;
+ DATA_BLOB data = dgram_mailslot_data(dgram);
NTSTATUS status;
- status = ndr_pull_struct_blob(data, mem_ctx, netlogon,
+ status = ndr_pull_struct_blob(&data, mem_ctx, netlogon,
(ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to parse netlogon packet of length %d\n",
- data->length));
+ data.length));
#if 0
- file_save("netlogon.dat", data->data, data->length);
+ file_save("netlogon.dat", data.data, data.length);
#endif
}
return status;
diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c
index 7f18e8cec6..1c1f138b1e 100644
--- a/source4/libcli/dgram/ntlogon.c
+++ b/source4/libcli/dgram/ntlogon.c
@@ -101,16 +101,16 @@ NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *dgram,
struct nbt_ntlogon_packet *ntlogon)
{
- DATA_BLOB *data = &dgram->data.msg.body.smb.body.trans.data;
+ DATA_BLOB data = dgram_mailslot_data(dgram);
NTSTATUS status;
- status = ndr_pull_struct_blob(data, mem_ctx, ntlogon,
+ status = ndr_pull_struct_blob(&data, mem_ctx, ntlogon,
(ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to parse ntlogon packet of length %d\n",
- data->length));
+ data.length));
#if 0
- file_save("ntlogon.dat", data->data, data->length);
+ file_save("ntlogon.dat", data.data, data.length);
#endif
}
return status;