Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/vfs/cpio/cpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat
// FIXME: do we must read from arch->fd in case of inode != NULL only or in any
// case?

inode->linkname = g_malloc (st->st_size + 1);
if (st->st_size < 0 || st->st_size > MC_MAXPATHLEN)
return STATUS_FAIL;
inode->linkname = g_malloc ((gsize) st->st_size + 1);

if (mc_read (arch->fd, inode->linkname, st->st_size) < st->st_size)
{
Expand Down Expand Up @@ -597,7 +599,12 @@ cpio_read_bin_head (struct vfs_class *me, struct vfs_s_super *super)
st.st_rdev = u.buf.c_rdev;
#endif
st.st_size = ((off_t) u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1];

if (st.st_size < 0)
{
message (D_ERROR, MSG_ERROR, _ ("Corrupted cpio header encountered in\n%s"), super->name);
g_free (name);
return STATUS_FAIL;
}
vfs_zero_stat_times (&st);

st.st_atime = st.st_mtime = st.st_ctime =
Expand Down Expand Up @@ -751,7 +758,12 @@ cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super)
u.st.st_rdev = makedev (hd.c_rdev, hd.c_rdevmin);
#endif
u.st.st_size = hd.c_filesize;

if (u.st.st_size < 0)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are completely right. I have update the PR w newer fix.

message (D_ERROR, MSG_ERROR, _ ("Corrupted cpio header encountered in\n%s"), super->name);
g_free (name);
return STATUS_FAIL;
}
vfs_zero_stat_times (&u.st);
u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;

Expand Down
Loading