aboutsummaryrefslogtreecommitdiff
path: root/src/copyin.c
AgeCommit message (Collapse)AuthorFiles
2024-01-14Upgrade copyright yearsSergey Poznyakoff1
2023-05-18Fix operation of --no-absolute-filenames --make-directoriesSergey Poznyakoff1
* src/copyin.c (symlink_placeholder): Try to create leading directories if unable to create placeholder.
2023-05-17Restore access and modification times of symlinks in copy-in and copy-pass ↵Sergey Poznyakoff1
modes. * gnulib.modules: Replace utimens with fdutimensat. * paxutils: Upgrade. * src/copyin.c: Update calls to set_file_times. (copyin_link,replace_symlink_placeholders): Call set_file_times if needed. * src/copyout.c: Update calls to set_file_times. * src/copypass.c (process_copy_pass): Update calls to set_file_times. Call set_file_times to restore times of extracted symlinks. * src/extern.h (set_file_times): Take additional argument. * src/util.c (set_file_times): Take additional argument. Use fdutimensat to do the job. * tests/linktime.at: New file. * tests/linktime01.at: New file. * tests/Makefile.am: Add new files. * tests/testsuite.at: Include new tests.
2023-04-28Use GNU ls algorithm for deciding timestamp formatPaul Eggert1
Problem reported by Dan Jacobson (Bug#50694). * gnulib.modules: Add gettime, timespec. * src/copyin.c: Include timespec.h. (current_time): Now struct timespec, not time_t. All uses changed. (long_format): When formatting a timestamp, use the same algorithm that GNU ls does to decide whether a file is recent.
2023-04-28Fix integer overflows in timestamp outputPaul Eggert1
* src/copyin.c (long_format): Fix some unlikely integer overflow bugs. Work even if (current_time - when) overflows, which is possible if time_t is unsigned. Do not assume that system integer types fit into unsigned long. Simplify by using %ju. No need for local tbuf array.
2023-04-28Whitespace cleanupSergey Poznyakoff1
2023-04-28Fix 45b0ee2b407913c533f7ded8d6f8cbeec16ff6ca.Sergey Poznyakoff1
The commit in question brought in more problems than solutions. To properly fix the issue, use symlink placeholders, modelled after delayed symlinks in tar. * src/copyin.c (symlink_placeholder) (replace_symlink_placeholders): New functions. (copyin_link): Create symlink placeholder if --no-absolute-filenames was given. (process_copy_in): Replace placeholders after extraction. * tests/CVE-2015-1197.at: Update. Don't use /tmp.
2023-01-22Update copyright yearsSergey Poznyakoff1
2022-01-02Update copyright yearsSergey Poznyakoff1
2021-08-07Rewrite dynamic string support.Sergey Poznyakoff1
* src/dstring.c (ds_init): Take a single argument. (ds_free): New function. (ds_resize): Take a single argument. Use x2nrealloc to expand the storage. (ds_reset,ds_append,ds_concat,ds_endswith): New function. (ds_fgetstr): Rewrite. In particular, this fixes integer overflow. * src/dstring.h (dynamic_string): Keep both the allocated length (ds_size) and index of the next free byte in the string (ds_idx). (ds_init,ds_resize): Change signature. (ds_len): New macro. (ds_free,ds_reset,ds_append,ds_concat,ds_endswith): New protos. * src/copyin.c: Use new ds_ functions. * src/copyout.c: Likewise. * src/copypass.c: Likewise. * src/util.c: Likewise.
2021-03-24Improve online version of the documentation.Sergey Poznyakoff1
2021-01-08Update gnulibSergey Poznyakoff1
* NEWS: Raise version number. * configure.ac: Raise version number to 2.13.90. Raise autoconf and automake requirements. * gnulib: Pull v0.1-4336-gbdae9a5 * gnulib.modules: Remove getopt * src/copyin.c (long_format): Cast rdev numbers to unsigned long
2021-01-06Update copyright yearsSergey Poznyakoff1
2020-02-08Update copyright yearsSergey Poznyakoff1
2019-11-08Improve 684b7ac5Sergey Poznyakoff1
* src/copyin.c (read_name_from_file): Handle len == 0.
2019-11-08Fix cpio header verification.Sergey Poznyakoff1
* src/copyin.c (read_name_from_file): Print error message and skip file if its name is not nul-terminated.
2019-11-06Version 2.13release_2_13Sergey Poznyakoff1
* NEWS: Describe new version. * configure.ac: version 2.13 * src/copyin.c: Fix strict aliasing violation. * tests/CVE-2019-14866.at: New file. * tests/Makefile.am: Add new test. * tests/testsuite.at: Add new test,
2019-11-04Various fixesSergey Poznyakoff1
* doc/cpio.texi: Document URLs of the mailing list archive and subscription interface. * src/copyin.c (try_existing_file): Change type of the last argument. (copyin_file): Initialize existing_dir. * src/dstring.c: Include xalloc.h * src/filemode.c (mode_string): mode is unsigned int.
2019-11-03Fix CVE-2015-1197Sergey Poznyakoff1
* src/copyin.c (copyin_link): Force safer name suffix for symbolic links. * tests/CVE-2015-1197.at: New file. * tests/Makefile.am: Add new test case. * tests/testsuite.at: Likewise.
2019-11-03Provide functions for struct cpio_file_stat management.Sergey Poznyakoff1
* src/copyin.c (long_format): Mark unchangeable argument as const. (read_name_from_file): Use cpio_realloc_c_name. (process_copy_in): Use CPIO_FILE_STAT_INITIALIZER. Call cpio_file_stat_free before return. * src/copyout.c (process_copy_out): Likewise. * src/copypass.c (link_to_name): Mark unchangeable argument as const. * src/cpiohdr.h (cpio_file_stat) <c_name_buflen>: New member, <c_tar_linkname>: Mark as const. (CPIO_FILE_STAT_INITIALIZER): New define. (cpio_file_stat_init,cpio_file_stat_free) (cpio_realloc_c_name): New protos. * src/extern.h: Fix prototypes. * src/makepath.c (make_path): Mark unchangeable argument as const. * src/util.c (create_all_directories): Mark unchangeable argument as const. (cpio_realloc_c_name): New function. (cpio_set_c_name): Use cpio_realloc_c_name. (cpio_file_stat_init,cpio_file_stat_free): New functions.
2018-12-01Minor fixesSergey Poznyakoff1
* src/copyin.c: Remove unused variable. * src/util.c: Cast arguments to printf.
2017-04-14CVE-2016-2037 - 1 byte out-of-bounds writePavel Raiskup1
Ensure that cpio_safer_name_suffix always works with dynamically allocated buffer, and that it has size of at least 32 bytes. Then, any call to cpio_safer_name_suffix is safe (it requires at least 2 bytes in the buffer). Also ensure that c_namesize is always correctly initialized (by cpio_set_c_name) to avoid undefined behavior when reading file_hdr.c_namesize (previously happened for tar archives). References: http://www.mail-archive.com/bug-cpio@gnu.org/msg00545.html * src/copyin.c (query_rename): Drop the hack, as we now work with dynamically allocated buffer. Use cpio_set_c_name. (create_defered_links_to_skipped): Use cpio_set_c_name rather than manual assignment. (read_name_from_file): New function to avoid C&P. (read_in_old_ascii, read_in_new_ascii, read_in_binary): Use read_name_from_file. (process_copy_in): Initialize file_hdr.c_namesize. * src/copyout.c (process_copy_out): Use cpio_set_c_name. * src/cpiohdr.h (cpio_set_c_name): New prototype. * src/tar.c (read_in_tar_header): Use cpio_set_c_name. * src/util.c (cpio_set_c_name): New function to set file_hdr->c_name and c_namesize from arbitrary string. (cpio_safer_name_suffix): Some docs fixes. * tests/inout.at: Also test copy-in, and try various formats.
2017-01-02Update copyright yearsSergey Poznyakoff1
2016-11-10Fix the output of UTF8 file names in verbose mode.Sergey Poznyakoff1
* am/quoting.m4: New file. * configure.ac: Set default quoting style. * src/copyin.c (long_format): Use quotearg. (print_name_with_quoting): Remove. * src/extern.h (print_name_with_quoting): Remove proto.
2016-11-10Fix out-of-bounds readSergey Poznyakoff1
* src/copyin.c (process_copy_in): Skip records with zero filename length.
2015-09-12Update docs, use gettext 0.19.6Sergey Poznyakoff1
2015-09-01Include gnulib and paxutils as submodules.Sergey Poznyakoff1
* gnulib: New submodule. * paxutils: New submodule. * .gitignore: Updage * .gitmodules: Update * README-hacking: Update. * bootstrap: Install slightly modified version from the gnulib repo. * bootstrap.conf: Add paxutils-related stuff. * po/.gitignore: Update. * tests/symlink-bad-length.at: Fix expected output. * src/copyin.c: Tiny change. * src/util.c: Likewise.
2014-12-11Fix error recovery in copy-in modeSergey Poznyakoff1
* src/copyin.c (copyin_link): Fix null dereference. (read_in_header): Fix error recovery (bug introduced by 27e0ae55). * tests/symlink-bad-length.at: Test error recovery. Catch various architecture-dependent error messages (suggested by Pavel Raiskup).
2014-12-02Fix typoSergey Poznyakoff1
2014-12-01BugfixSergey Poznyakoff1
* src/copyin.c (get_link_name): Fix range checking. * tests/symlink-bad-length.at: Change expected error message.
2014-12-01Fix memory overrun on reading improperly created link records.Sergey Poznyakoff1
See http://lists.gnu.org/archive/html/bug-cpio/2014-11/msg00007.html * src/copyin.c (get_link_name): New function. (list_file, copyin_link): use get_link_name * tests/symlink-bad-length.at: New file. * tests/symlink-long.at: New file. * tests/Makefile.am: Add new files. * tests/testsuite.at: Likewise.
2014-01-30Update copyright years.Sergey Poznyakoff1
2014-01-30Use exit codes consistenly.Sergey Poznyakoff1
2012-02-20Always use 32 bit CRCSergey Poznyakoff1
* src/cpiohdr.h (cpio_file_stat) <c_chksum>: Change type to uint32_t. * src/extern.h (crc): Change type to uint32_t. * src/global.c: Likewise. * src/copyout.c (read_for_checksum): Return uint32_t. * src/copyin.c: Fix printf formats.
2011-09-19Fix error handling in disk_empty_output_buffer and sparse_writeSergey Poznyakoff1
* src/extern.h (delayed_seek_count): Remove. (disk_empty_output_buffer): Change signature. * src/util.c (disk_empty_output_buffer): Take two arguments. Correctly handle partial writes (errno is not meaningful). (delayed_seek_count): Remove variable. (sparse_write): Change return type and signature. Rewrite. Return number actual number of bytes written or -1 on error. Check returns from lseek and write. * src/copyin.c (copyin_regular_file): Call disk_empty_output_buffer with flush=true before closing the file. * src/copypass.c (process_copy_pass): Likewise.
2011-09-19Minor fixes.Sergey Poznyakoff1
* configure.ac: Use gettext 0.18 * doc/.gitignore: Add parse-datetime.texi. * lib/Makefile.am (libpax_a_SOURCES): Add exit-status.c * src/copyin.c (read_pattern_file): Use open_fatal if opening pattern file failed. * src/util.c (set_file_times): Use fdutimens.
2010-07-22Provide a tar-like --directory (-D) option.Sergey Poznyakoff1
* src/copyin.c (process_copy_in): Call change_dir. * src/copyout.c (process_copy_out): Likewise. * src/copypass.c (process_copy_pass): Likewise. * src/extern.h (change_directory_option): New extern. (change_dir): New proto. * src/global.c (change_directory_option): New global. * src/main.c (options): New option --directory. (parse_opt): Handle the --directory option. * src/util.c (change_dir): New proto. * doc/cpio.texi: Document the --directory option.
2010-07-22Fix --to-stdout option supportDmitry V. Levin1
* src/copyin.c (copyin_link): Skip an appropriate number of bytes when to_stdout_option flag is set. * tests/symlink-to-stdout.at: New test case. * tests/Makefile.am (TESTSUITE_AT): Add symlink-to-stdout.at. * tests/testsuite.at: Include symlink-to-stdout.at.
2010-02-12Use same code when creating directories in copy-in and copy-pass modes.Sergey Poznyakoff1
* src/copyin.c (copyin_mkdir): Remove. (copyin_directory): Remove. (copyin_file): Use cpio_create_dir instead of copyin_directory. * src/copypass.c (process_copy_pass): Use cpio_create_dir to create directories. * src/extern.h (delay_cpio_set_stat): New proto. * src/util.c (delay_cpio_set_stat): New function. (delay_set_stat): Rewrite as a wrapper to the above. (cpio_create_dir): New function. * tests/setstat01.at: Fix testcase. * tests/setstat02.at: Likewise. * tests/setstat03.at: New testcase. * tests/setstat04.at: New testcase. * tests/setstat05.at: New testcase. * tests/Makefile.am: Add new testcases. * tests/testsuite.at: Likewise.
2010-02-11Fix inode number typing.Sergey Poznyakoff1
* src/copyin.c (create_defered_links): Use ino_t for inode numbers. (create_defered_links_to_skipped): Likewise. (process_copy_in): Add typecast to inode fprintf argument. * src/copyout.c (count_defered_links_to_dev_ino) (writeout_other_defers): Use ino_t for inode numbers. * src/copypass.c (link_to_maj_min_ino): Likewise. * src/util.c (struct inode_val): Likewise. (find_inode_file, add_inode): Likewise. * src/extern.h (link_to_maj_min_ino) (find_inode_file, add_inode): Change signature.
2010-02-11Update copyright years.Sergey Poznyakoff1
2009-07-31Delay setting directory attributes until end of run, if they do not permit ↵Sergey Poznyakoff1
writing. Fix debian bug #458079. * src/copyin.c (copyin_mkdir): New function. (copyin_directory): Use copyin_mkdir to create directory. Call set_perms only when safe, otherwise use repair_delayed_set_stat. * src/extern.h (cpio_to_stat): New prototype. (repair_delayed_set_stat): Change prototype. * src/util.c (cpio_to_stat): New function. (repair_delayed_set_stat): New function. * tests/setstat01.at: New test case. * tests/setstat02.at: New test case. * tests/Makefile.am (TESTSUITE_AT): Add setstat01.at and setstat02.at * tests/testsuite.at: Include setstat01.at and setstat02.at. * NEWS: Update.
2009-07-31Fix mt and make sure it is always build during distcheck.Sergey Poznyakoff1
Minor fixes in cpio. * Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): New variable. Ensure that distcheck builds mt. * bootstrap: Patch Makefile.in to honor AM_DISTCHECK_CONFIGURE_FLAGS. * gnulib.modules: add argp-version-etc and progname. * src/Makefile.am: Remove useless dependency. * src/copyin.c (long_format): Fix printf arguments. * src/copyout.c (read_for_checksum): Return unsigned long. (process_copy_out): Remove unused variable. * src/extern.h (crc): Change type to unsigned long. (program_name): Remove. * src/global.c: Likewise. * src/main.c: Include argp-version-etc.h and progname.h (argp_program_version): Remove. (program_authors): New global. (options): Remove the 'Informative options' group. These are handled automatically by argp. (parse_opt): Likewise. (licence): Remove. This info is output by --version. (process_args): Remove useless test. (main): Use set_program_name and argp_version_setup. * src/mt.c: Remove superfluous includes. Include argp-version-etc.h and progname.h Use argp to parse arguments. Supply the fatal_exit function. * tests/version.at: Update for the new --version output. * THANKS: Add Peter Breitenlohner. * AUTHORS: Update Sergey's email.
2007-09-28Fix passing improper argument to swab_array.Sergey Poznyakoff1
2007-06-28Save current umask before processing and call apply_delayed_set_stat afterwardsSergey Poznyakoff1
2007-06-28Number of blocks is size_t.Sergey Poznyakoff1
2007-06-27Relicense under GPLv3Sergey Poznyakoff1
2007-06-07Update calls to set_perms.Sergey Poznyakoff1
2007-05-18(from_ascii): Bugfix: allow for empty fieldsSergey Poznyakoff1
2006-12-18Update (long_format): Use PRIuMAX for printing file sizeSergey Poznyakoff1

Return to:

Send suggestions and report system problems to the System administrator.