(cpio_read_bin_head): fix unintended sign extension.

If c_filesizes[0] is greater than 0x7fff implicit sign extension will happen on bit shift.

Found by Coverity.
Coverity id #32611.
Coverity id #32612.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andreas Mohr 2020-12-21 11:40:12 +00:00 committed by Andrew Borodin
parent d37dbcca4c
commit f57e69ad29

View File

@ -603,11 +603,12 @@ cpio_read_bin_head (struct vfs_class *me, struct vfs_s_super *super)
#ifdef HAVE_STRUCT_STAT_ST_RDEV
st.st_rdev = u.buf.c_rdev;
#endif
st.st_size = (u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1];
st.st_size = ((off_t) u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1];
#ifdef HAVE_STRUCT_STAT_ST_MTIM
st.st_atim.tv_nsec = st.st_mtim.tv_nsec = st.st_ctim.tv_nsec = 0;
#endif
st.st_atime = st.st_mtime = st.st_ctime = (u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1];
st.st_atime = st.st_mtime = st.st_ctime =
((time_t) u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1];
return cpio_create_entry (me, super, &st, name);
}