Author: metze Date: 2006-05-11 10:47:37 +0000 (Thu, 11 May 2006) New Revision: 15532
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15532 Log: add a BOOL body_dynamic_present, because the body_dynamic_size can be 0 also if the dynamic flag should be set metze Modified: branches/SAMBA_4_0/source/libcli/smb2/close.c branches/SAMBA_4_0/source/libcli/smb2/create.c branches/SAMBA_4_0/source/libcli/smb2/find.c branches/SAMBA_4_0/source/libcli/smb2/flush.c branches/SAMBA_4_0/source/libcli/smb2/getinfo.c branches/SAMBA_4_0/source/libcli/smb2/ioctl.c branches/SAMBA_4_0/source/libcli/smb2/keepalive.c branches/SAMBA_4_0/source/libcli/smb2/logoff.c branches/SAMBA_4_0/source/libcli/smb2/negprot.c branches/SAMBA_4_0/source/libcli/smb2/read.c branches/SAMBA_4_0/source/libcli/smb2/request.c branches/SAMBA_4_0/source/libcli/smb2/session.c branches/SAMBA_4_0/source/libcli/smb2/setinfo.c branches/SAMBA_4_0/source/libcli/smb2/tcon.c branches/SAMBA_4_0/source/libcli/smb2/tdis.c branches/SAMBA_4_0/source/libcli/smb2/write.c branches/SAMBA_4_0/source/smb_server/smb2/keepalive.c branches/SAMBA_4_0/source/smb_server/smb2/negprot.c branches/SAMBA_4_0/source/smb_server/smb2/receive.c branches/SAMBA_4_0/source/smb_server/smb2/sesssetup.c branches/SAMBA_4_0/source/smb_server/smb2/tcon.c branches/SAMBA_4_0/source/torture/smb2/scan.c Changeset: Modified: branches/SAMBA_4_0/source/libcli/smb2/close.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/close.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/close.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -32,7 +32,7 @@ { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, 0); + req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.flags); Modified: branches/SAMBA_4_0/source/libcli/smb2/create.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/create.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/create.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -67,7 +67,7 @@ NTSTATUS status; DATA_BLOB blob = data_blob(NULL, 0); - req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, 1); + req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, True, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.oplock_flags); Modified: branches/SAMBA_4_0/source/libcli/smb2/find.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/find.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/find.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -33,7 +33,7 @@ struct smb2_request *req; NTSTATUS status; - req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, 1); + req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, True, 0); if (req == NULL) return NULL; SCVAL(req->out.body, 0x02, io->in.level); Modified: branches/SAMBA_4_0/source/libcli/smb2/flush.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/flush.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/flush.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -31,7 +31,7 @@ { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, 0); + req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, False, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, 0); /* pad? */ Modified: branches/SAMBA_4_0/source/libcli/smb2/getinfo.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/getinfo.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/getinfo.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -32,7 +32,7 @@ { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, 0); + req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0); if (req == NULL) return NULL; /* this seems to be a bug, they use 0x29 but only send 0x28 bytes */ Modified: branches/SAMBA_4_0/source/libcli/smb2/ioctl.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/ioctl.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/ioctl.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -32,7 +32,7 @@ NTSTATUS status; struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, + req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, True, io->in.in.length+io->in.out.length); if (req == NULL) return NULL; Modified: branches/SAMBA_4_0/source/libcli/smb2/keepalive.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/keepalive.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/keepalive.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -31,7 +31,7 @@ { struct smb2_request *req; - req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, 0); + req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, False, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, 0); Modified: branches/SAMBA_4_0/source/libcli/smb2/logoff.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/logoff.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/logoff.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -31,7 +31,7 @@ { struct smb2_request *req; - req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, 0); + req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, False, 0); if (req == NULL) return NULL; SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid); Modified: branches/SAMBA_4_0/source/libcli/smb2/negprot.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/negprot.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/negprot.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -33,7 +33,7 @@ { struct smb2_request *req; - req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, 0); + req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, False, 0); if (req == NULL) return NULL; /* this seems to be a bug, they use 0x24 but the length is 0x26 */ Modified: branches/SAMBA_4_0/source/libcli/smb2/read.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/read.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/read.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -31,7 +31,7 @@ { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x31, 0); + req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x31, False, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, 0); /* pad */ Modified: branches/SAMBA_4_0/source/libcli/smb2/request.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/request.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/request.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -31,10 +31,19 @@ initialise a smb2 request */ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_t opcode, - uint16_t body_fixed_size, uint32_t body_dynamic_size) + uint16_t body_fixed_size, BOOL body_dynamic_present, + uint32_t body_dynamic_size) { struct smb2_request *req; + if (body_dynamic_present) { + if (body_dynamic_size == 0) { + body_dynamic_size = 1; + } + } else { + body_dynamic_size = 0; + } + req = talloc(transport, struct smb2_request); if (req == NULL) return NULL; @@ -95,10 +104,12 @@ initialise a smb2 request for tree operations */ struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opcode, - uint16_t body_fixed_size, uint32_t body_dynamic_size) + uint16_t body_fixed_size, BOOL body_dynamic_present, + uint32_t body_dynamic_size) { struct smb2_request *req = smb2_request_init(tree->session->transport, opcode, - body_fixed_size, body_dynamic_size); + body_fixed_size, body_dynamic_present, + body_dynamic_size); if (req == NULL) return NULL; SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid); Modified: branches/SAMBA_4_0/source/libcli/smb2/session.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/session.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/session.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -69,7 +69,7 @@ NTSTATUS status; req = smb2_request_init(session->transport, SMB2_OP_SESSSETUP, - 0x10, io->in.secblob.length); + 0x10, True, io->in.secblob.length); if (req == NULL) return NULL; SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid); Modified: branches/SAMBA_4_0/source/libcli/smb2/setinfo.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/setinfo.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/setinfo.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -33,7 +33,7 @@ NTSTATUS status; struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, io->in.blob.length); + req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, True, io->in.blob.length); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.level); Modified: branches/SAMBA_4_0/source/libcli/smb2/tcon.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/tcon.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/tcon.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -54,7 +54,7 @@ NTSTATUS status; req = smb2_request_init(tree->session->transport, SMB2_OP_TCON, - 0x08, 1); + 0x08, True, 0); if (req == NULL) return NULL; SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid); Modified: branches/SAMBA_4_0/source/libcli/smb2/tdis.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/tdis.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/tdis.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -31,7 +31,7 @@ { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, 0); + req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, False, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, 0); Modified: branches/SAMBA_4_0/source/libcli/smb2/write.c =================================================================== --- branches/SAMBA_4_0/source/libcli/smb2/write.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/libcli/smb2/write.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -32,7 +32,7 @@ NTSTATUS status; struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, io->in.data.length); + req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, True, io->in.data.length); if (req == NULL) return NULL; status = smb2_push_o16s32_blob(&req->out, 0x02, io->in.data); Modified: branches/SAMBA_4_0/source/smb_server/smb2/keepalive.c =================================================================== --- branches/SAMBA_4_0/source/smb_server/smb2/keepalive.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/smb_server/smb2/keepalive.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -39,7 +39,7 @@ return; } - status = smb2srv_setup_reply(req, 0x04, 0); + status = smb2srv_setup_reply(req, 0x04, False, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); Modified: branches/SAMBA_4_0/source/smb_server/smb2/negprot.c =================================================================== --- branches/SAMBA_4_0/source/smb_server/smb2/negprot.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/smb_server/smb2/negprot.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -117,7 +117,7 @@ return; } - status = smb2srv_setup_reply(req, 0x40, io->out.secblob.length); + status = smb2srv_setup_reply(req, 0x40, True, io->out.secblob.length); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); Modified: branches/SAMBA_4_0/source/smb_server/smb2/receive.c =================================================================== --- branches/SAMBA_4_0/source/smb_server/smb2/receive.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/smb_server/smb2/receive.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -41,8 +41,17 @@ return req; } -NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint_t body_fixed_size, size_t body_dynamic_size) +NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_size, + BOOL body_dynamic_present, uint32_t body_dynamic_size) { + if (body_dynamic_present) { + if (body_dynamic_size == 0) { + body_dynamic_size = 1; + } + } else { + body_dynamic_size = 0; + } + req->out.size = SMB2_HDR_BODY+NBT_HDR_SIZE+body_fixed_size; req->out.allocated = req->out.size + body_dynamic_size; @@ -103,7 +112,7 @@ { NTSTATUS status; - status = smb2srv_setup_reply(req, 8, 1); + status = smb2srv_setup_reply(req, 8, True, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); Modified: branches/SAMBA_4_0/source/smb_server/smb2/sesssetup.c =================================================================== --- branches/SAMBA_4_0/source/smb_server/smb2/sesssetup.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/smb_server/smb2/sesssetup.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -126,7 +126,7 @@ return; } - status = smb2srv_setup_reply(req, 0x08, io->out.secblob.length); + status = smb2srv_setup_reply(req, 0x08, True, io->out.secblob.length); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); @@ -199,7 +199,7 @@ return; } - status = smb2srv_setup_reply(req, 0x04, 0); + status = smb2srv_setup_reply(req, 0x04, False, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); Modified: branches/SAMBA_4_0/source/smb_server/smb2/tcon.c =================================================================== --- branches/SAMBA_4_0/source/smb_server/smb2/tcon.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/smb_server/smb2/tcon.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -54,7 +54,7 @@ return; } - status = smb2srv_setup_reply(req, 0x10, 0); + status = smb2srv_setup_reply(req, 0x10, False, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); @@ -122,7 +122,7 @@ return; } - status = smb2srv_setup_reply(req, 0x04, 0); + status = smb2srv_setup_reply(req, 0x04, False, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); Modified: branches/SAMBA_4_0/source/torture/smb2/scan.c =================================================================== --- branches/SAMBA_4_0/source/torture/smb2/scan.c 2006-05-11 09:04:24 UTC (rev 15531) +++ branches/SAMBA_4_0/source/torture/smb2/scan.c 2006-05-11 10:47:37 UTC (rev 15532) @@ -219,7 +219,7 @@ tree->session->transport->options.timeout = 3; for (opcode=0;opcode<1000;opcode++) { - req = smb2_request_init_tree(tree, opcode, 2, 0); + req = smb2_request_init_tree(tree, opcode, 2, False, 0); SSVAL(req->out.body, 0, 0); smb2_transport_send(req); if (!smb2_request_receive(req)) {