Due to integer promotion this won't make a difference if an 'int' is 4+
bytes anyway, but make the intention clear: this computation should not
overflow.
{
u64 length = sizeof(struct wim_dentry_on_disk);
if (file_name_nbytes)
{
u64 length = sizeof(struct wim_dentry_on_disk);
if (file_name_nbytes)
- length += file_name_nbytes + 2;
+ length += (u32)file_name_nbytes + 2;
- length += short_name_nbytes + 2;
+ length += (u32)short_name_nbytes + 2;
{
u64 len = sizeof(struct wim_ads_entry_on_disk);
if (entry->stream_name_nbytes)
{
u64 len = sizeof(struct wim_ads_entry_on_disk);
if (entry->stream_name_nbytes)
- len += entry->stream_name_nbytes + 2;
+ len += (u32)entry->stream_name_nbytes + 2;
static int
dentry_calculate_subdir_offset(struct wim_dentry *dentry, void *_subdir_offset_p)
{
static int
dentry_calculate_subdir_offset(struct wim_dentry *dentry, void *_subdir_offset_p)
{
if (dentry_is_directory(dentry)) {
u64 *subdir_offset_p = _subdir_offset_p;
struct wim_dentry *child;
if (dentry_is_directory(dentry)) {
u64 *subdir_offset_p = _subdir_offset_p;
struct wim_dentry *child;
goto err_free_dentry;
}
dentry->file_name_nbytes = file_name_nbytes;
goto err_free_dentry;
}
dentry->file_name_nbytes = file_name_nbytes;
- p += file_name_nbytes + 2;
+ p += (u32)file_name_nbytes + 2;
}
/* Read the short filename if present. Note: if there is no short
}
/* Read the short filename if present. Note: if there is no short
goto err_free_dentry;
}
dentry->short_name_nbytes = short_name_nbytes;
goto err_free_dentry;
}
dentry->short_name_nbytes = short_name_nbytes;
- p += short_name_nbytes + 2;
+ p += (u32)short_name_nbytes + 2;
}
/* Read extra data at end of dentry (but before alternate data stream
}
/* Read extra data at end of dentry (but before alternate data stream
p += sizeof(struct wim_ads_entry_on_disk);
if (ads_entry->stream_name_nbytes) {
p = mempcpy(p, ads_entry->stream_name,
p += sizeof(struct wim_ads_entry_on_disk);
if (ads_entry->stream_name_nbytes) {
p = mempcpy(p, ads_entry->stream_name,
- ads_entry->stream_name_nbytes + 2);
+ (u32)ads_entry->stream_name_nbytes + 2);
}
/* Align to 8-byte boundary */
while ((uintptr_t)p & 7)
}
/* Align to 8-byte boundary */
while ((uintptr_t)p & 7)
wimlib_assert(dentry_is_root(dentry) != dentry_has_long_name(dentry));
if (dentry_has_long_name(dentry))
wimlib_assert(dentry_is_root(dentry) != dentry_has_long_name(dentry));
if (dentry_has_long_name(dentry))
- p = mempcpy(p, dentry->file_name, dentry->file_name_nbytes + 2);
+ p = mempcpy(p, dentry->file_name, (u32)dentry->file_name_nbytes + 2);
if (dentry_has_short_name(dentry))
if (dentry_has_short_name(dentry))
- p = mempcpy(p, dentry->short_name, dentry->short_name_nbytes + 2);
+ p = mempcpy(p, dentry->short_name, (u32)dentry->short_name_nbytes + 2);
/* Align to 8-byte boundary */
while ((uintptr_t)p & 7)
/* Align to 8-byte boundary */
while ((uintptr_t)p & 7)