pass in the required alignment to the EA construction routines
authorAndrew Tridgell <tridge@samba.org>
Thu, 22 May 2008 12:46:29 +0000 (22:46 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 22 May 2008 12:46:29 +0000 (22:46 +1000)
(This used to be commit af31030e0b78b6b220740529901ec8d2d9f5a3fe)

source4/libcli/raw/raweas.c
source4/libcli/raw/rawfile.c
source4/libcli/smb2/create.c
source4/smb_server/blob.c

index 8ea8e621c9fedcab98f0d3e9f621987e6a15fbb1..07b517ade3f24bec4fdfc8622bc13a9b0e6dbac0 100644 (file)
@@ -54,13 +54,13 @@ static uint_t ea_name_list_size(uint_t num_names, struct ea_name *eas)
   This assumes the names are strict ascii, which should be a
   reasonable assumption
 */
-size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas)
+size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas, unsigned alignment)
 {
        uint_t total = 0;
        int i;
        for (i=0;i<num_eas;i++) {
                uint_t len = 8 + strlen(eas[i].name.s)+1 + eas[i].value.length;
-               len = (len + 3) & ~3;
+               len = (len + (alignment-1)) & ~(alignment-1);
                total += len;
        }
        return total;
@@ -96,14 +96,15 @@ void ea_put_list(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
   put a chained ea_list into a pre-allocated buffer - buffer must be
   at least of size ea_list_size()
 */
-void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
+void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas,
+                        unsigned alignment)
 {
        int i;
 
        for (i=0;i<num_eas;i++) {
                uint_t nlen = strlen(eas[i].name.s);
                uint32_t len = 8+nlen+1+eas[i].value.length;
-               uint_t pad = ((len + 3) & ~3) - len;
+               uint_t pad = ((len + (alignment-1)) & ~(alignment-1)) - len;
                if (i == num_eas-1) {
                        SIVAL(data, 0, 0);
                } else {
index 3c5c1b742bd09dfe6f465e15017021d4d311e334..d39c61551be7b0b2f4158c04b01160dddb45c242 100644 (file)
@@ -314,14 +314,14 @@ static struct smbcli_request *smb_raw_nttrans_create_send(struct smbcli_tree *tr
 
        if (parms->ntcreatex.in.ea_list) {
                uint32_t ea_size = ea_list_size_chained(parms->ntcreatex.in.ea_list->num_eas,
-                                                       parms->ntcreatex.in.ea_list->eas);
+                                                       parms->ntcreatex.in.ea_list->eas, 4);
                ea_blob = data_blob_talloc(mem_ctx, NULL, ea_size);
                if (ea_blob.data == NULL) {
                        return NULL;
                }
                ea_put_list_chained(ea_blob.data, 
                                    parms->ntcreatex.in.ea_list->num_eas,
-                                   parms->ntcreatex.in.ea_list->eas);
+                                   parms->ntcreatex.in.ea_list->eas, 4);
        }
 
        nt.in.params = data_blob_talloc(mem_ctx, NULL, 53);
index 6ac32a494fcae747bcd9442dc97d9f6aed8db5a4..9d28bbf8c46a101e7bd9b287e973bfc09ad2ed4e 100644 (file)
@@ -117,8 +117,8 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
 
        if (io->in.eas.num_eas != 0) {
                DATA_BLOB b = data_blob_talloc(req, NULL, 
-                                              ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
-               ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas);
+                                              ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas, 8));
+               ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas, 8);
                status = smb2_create_blob_add(req, &io->in.blobs,
                                              SMB2_CREATE_TAG_EXTA, b);
                if (!NT_STATUS_IS_OK(status)) {
index 65cdd2aea646e81ef1c1256b8398b415a85aae92..cea4c60e5905f26a385a1a8177e3d9b479893de8 100644 (file)
@@ -476,12 +476,12 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
                }
 
                list_size = ea_list_size_chained(st->all_eas.out.num_eas,
-                                                st->all_eas.out.eas);
+                                                st->all_eas.out.eas, 8);
                BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx, blob, list_size));
 
                ea_put_list_chained(blob->data,
                                    st->all_eas.out.num_eas,
-                                   st->all_eas.out.eas);
+                                   st->all_eas.out.eas, 8);
                return NT_STATUS_OK;
 
        case RAW_FILEINFO_SMB2_ALL_INFORMATION: