]> wimlib.net Git - wimlib/commitdiff
tagged_items.c: length should be rounded up when adding item
authorEric Biggers <ebiggers3@gmail.com>
Sun, 14 Dec 2014 01:40:02 +0000 (19:40 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 14 Dec 2014 04:43:31 +0000 (22:43 -0600)
Also 0-fill the new item, including the padding.

These changes have no effect on the only caller of
inode_add_tagged_item() but should be made for correctness in case this
function gets more callers in the future.

src/tagged_items.c

index 86ad33e613a1490835510d6d91a3a500d7960115..e3ba53f496612c7d95e8dabaa12d3512865edca6 100644 (file)
@@ -116,7 +116,7 @@ inode_add_tagged_item(struct wim_inode *inode, u32 tag, u32 len)
 
        /* We prepend the item instead of appending it because it's easier.  */
 
 
        /* We prepend the item instead of appending it because it's easier.  */
 
-       itemsize = sizeof(struct tagged_item_header) + len;
+       itemsize = sizeof(struct tagged_item_header) + ((len + 7) & ~7);
        newsize = itemsize + inode->i_extra_size;
 
        buf = MALLOC(newsize);
        newsize = itemsize + inode->i_extra_size;
 
        buf = MALLOC(newsize);
@@ -133,7 +133,7 @@ inode_add_tagged_item(struct wim_inode *inode, u32 tag, u32 len)
        hdr = (struct tagged_item_header *)buf;
        hdr->tag = cpu_to_le32(tag);
        hdr->length = cpu_to_le32(len);
        hdr = (struct tagged_item_header *)buf;
        hdr->tag = cpu_to_le32(tag);
        hdr->length = cpu_to_le32(len);
-       return hdr->data;
+       return memset(hdr->data, 0, (len + 7) & ~7);
 }
 
 static inline struct wimlib_unix_data_disk *
 }
 
 static inline struct wimlib_unix_data_disk *