From d461f97a4acc36f9b98240cc6ce7e87a98fdd7cd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 23 Sep 2006 02:45:06 +0000 Subject: r18839: align all directory search blobs on an 8 byte boundary to keep the current vista release happy. (This used to be commit d3f0114a9dc8458cccfda71087668b1ddf4d380c) --- source4/smb_server/blob.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source4') diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c index 2fedc81678..0b38d3901d 100644 --- a/source4/smb_server/blob.c +++ b/source4/smb_server/blob.c @@ -38,6 +38,15 @@ } \ } while (0) + +/* align the end of the blob on an 8 byte boundary */ +#define BLOB_ALIGN(blob, alignment) do { \ + if ((blob)->length & ((alignment)-1)) { \ + uint8_t _pad = (alignment) - ((blob)->length & ((alignment)-1)); \ + BLOB_CHECK(smbsrv_blob_fill_data(blob, blob, (blob)->length+_pad)); \ + } \ +} while (0) + /* grow the data size of a trans2 reply */ NTSTATUS smbsrv_blob_grow_data(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, @@ -616,6 +625,7 @@ NTSTATUS smbsrv_push_passthru_search(TALLOC_CTX *mem_ctx, BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob, file->directory_info.name.s, ofs + 60, default_str_flags, STR_TERMINATE_ASCII)); + BLOB_ALIGN(blob, 8); data = blob->data + ofs; SIVAL(data, 0, blob->length - ofs); return NT_STATUS_OK; @@ -635,6 +645,7 @@ NTSTATUS smbsrv_push_passthru_search(TALLOC_CTX *mem_ctx, BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob, file->full_directory_info.name.s, ofs + 60, default_str_flags, STR_TERMINATE_ASCII)); + BLOB_ALIGN(blob, 8); data = blob->data + ofs; SIVAL(data, 0, blob->length - ofs); return NT_STATUS_OK; @@ -646,6 +657,7 @@ NTSTATUS smbsrv_push_passthru_search(TALLOC_CTX *mem_ctx, BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob, file->name_info.name.s, ofs + 8, default_str_flags, STR_TERMINATE_ASCII)); + BLOB_ALIGN(blob, 8); data = blob->data + ofs; SIVAL(data, 0, blob->length - ofs); return NT_STATUS_OK; @@ -672,10 +684,7 @@ NTSTATUS smbsrv_push_passthru_search(TALLOC_CTX *mem_ctx, BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob, file->both_directory_info.name.s, ofs + 60, default_str_flags, STR_TERMINATE_ASCII)); - /* align the end of the blob on an even boundary */ - if (blob->length & 1) { - BLOB_CHECK(smbsrv_blob_fill_data(blob, blob, blob->length+1)); - } + BLOB_ALIGN(blob, 8); data = blob->data + ofs; SIVAL(data, 0, blob->length - ofs); return NT_STATUS_OK; @@ -697,6 +706,7 @@ NTSTATUS smbsrv_push_passthru_search(TALLOC_CTX *mem_ctx, BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob, file->id_full_directory_info.name.s, ofs + 60, default_str_flags, STR_TERMINATE_ASCII)); + BLOB_ALIGN(blob, 8); data = blob->data + ofs; SIVAL(data, 0, blob->length - ofs); return NT_STATUS_OK; @@ -724,6 +734,7 @@ NTSTATUS smbsrv_push_passthru_search(TALLOC_CTX *mem_ctx, BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob, file->id_both_directory_info.name.s, ofs + 60, default_str_flags, STR_TERMINATE_ASCII)); + BLOB_ALIGN(blob, 8); data = blob->data + ofs; SIVAL(data, 0, blob->length - ofs); return NT_STATUS_OK; -- cgit