]> wimlib.net Git - wimlib/blobdiff - src/tagged_items.c
tagged_items.c: length should be rounded up when adding item
[wimlib] / src / tagged_items.c
index 0eee81d91409432f081305ef1395f6dec0e0f9e6..e3ba53f496612c7d95e8dabaa12d3512865edca6 100644 (file)
@@ -8,20 +8,18 @@
 /*
  * Copyright (C) 2014 Eric Biggers
  *
- * This file is part of wimlib, a library for working with WIM files.
+ * This file is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option) any
+ * later version.
  *
- * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * This file is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this file; if not, see http://www.gnu.org/licenses/.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -118,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.  */
 
-       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);
@@ -135,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);
-       return hdr->data;
+       return memset(hdr->data, 0, (len + 7) & ~7);
 }
 
 static inline struct wimlib_unix_data_disk *