mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 17:18:24 +08:00
Prevent archive memebers with illegal pathnames from being extracted from an archive.
PR binutils/17552, binutils/17533 * bucomm.c (is_valid_archive_path): New function. Returns false for absolute pathnames and pathnames that include /../. * bucomm.h (is_valid_archive_path): Add prototype. * ar.c (extract_file): Use new function to check for valid pathnames when extracting files from an archive. * objcopy.c (copy_archive): Likewise. * doc/binutils.texi: Update documentation to mention the limitation on pathname of archive members.
This commit is contained in:
@ -1034,6 +1034,15 @@ extract_file (bfd *abfd)
|
||||
bfd_size_type size;
|
||||
struct stat buf;
|
||||
|
||||
/* PR binutils/17533: Do not allow directory traversal
|
||||
outside of the current directory tree. */
|
||||
if (! is_valid_archive_path (bfd_get_filename (abfd)))
|
||||
{
|
||||
non_fatal (_("illegal pathname found in archive member: %s"),
|
||||
bfd_get_filename (abfd));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bfd_stat_arch_elt (abfd, &buf) != 0)
|
||||
/* xgettext:c-format */
|
||||
fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
|
||||
|
Reference in New Issue
Block a user