X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdentry.c;h=caa3a51b4b86fb0d98e84f103781cc0274499294;hp=13940a32d3b96c2a4c7d6f9a60babea8e3931ceb;hb=564aacbad3801ec37c2455e15b9296ecaef4eb93;hpb=c24f1c029572b67c7023aa06a7c24a46cf938367 diff --git a/src/dentry.c b/src/dentry.c index 13940a32..caa3a51b 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -358,7 +358,8 @@ dentry_out_total_length(const struct wim_dentry *dentry) dentry->d_short_name_nbytes); len = ALIGN(len, 8); - len += ALIGN(inode->i_extra_size, 8); + if (inode->i_extra) + len += ALIGN(inode->i_extra->size, 8); if (!(inode->i_attributes & FILE_ATTRIBUTE_ENCRYPTED)) { /* @@ -503,7 +504,8 @@ calculate_dentry_full_path(struct wim_dentry *dentry) d = dentry; do { p -= d->d_name_nbytes / sizeof(utf16lechar); - memcpy(p, d->d_name, d->d_name_nbytes); + if (d->d_name_nbytes) + memcpy(p, d->d_name, d->d_name_nbytes); *--p = cpu_to_le16(WIM_PATH_SEPARATOR); d = d->d_parent; /* assumes d == d->d_parent for root */ } while (!dentry_is_root(d)); @@ -1187,10 +1189,12 @@ read_extra_data(const u8 *p, const u8 *end, struct wim_inode *inode) p++; if (unlikely(p < end)) { - inode->i_extra = memdup(p, end - p); + inode->i_extra = MALLOC(sizeof(struct wim_inode_extra) + + end - p); if (!inode->i_extra) return WIMLIB_ERR_NOMEM; - inode->i_extra_size = end - p; + inode->i_extra->size = end - p; + memcpy(inode->i_extra->data, p, end - p); } return 0; } @@ -1774,9 +1778,9 @@ write_dentry(const struct wim_dentry * restrict dentry, u8 * restrict p) while ((uintptr_t)p & 7) *p++ = 0; - if (inode->i_extra_size) { + if (inode->i_extra) { /* Extra tagged items --- not usually present. */ - p = mempcpy(p, inode->i_extra, inode->i_extra_size); + p = mempcpy(p, inode->i_extra->data, inode->i_extra->size); /* Align to 8-byte boundary */ while ((uintptr_t)p & 7)