aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
AgeCommit message (Collapse)AuthorFiles
2024-01-14Upgrade copyright yearsSergey Poznyakoff1
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-28Fix appending to archives bigger than 2GSergey Poznyakoff1
* src/extern.h (last_header_start): Change type to off_t. * src/global.c: Likewise. * src/util.c (prepare_append): Use off_t for file offsets.
2023-01-22Update copyright yearsSergey Poznyakoff1
2022-01-02Update copyright yearsSergey Poznyakoff1
2021-09-03Remove redundant condition checkShreenidhi Shedi1
* src/util.c (tape_empty_output_buffer): Fix condition.
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-01-06Update copyright yearsSergey Poznyakoff1
2020-02-08Update copyright yearsSergey Poznyakoff1
2019-11-14Fix handling of device numbers on copy out.Sergey Poznyakoff1
Device minor and major numbers are meaningful only for devices. Don't attempt to store them for other files. Instead fill the corresponding fields with zeros. * src/util.c (stat_to_cpio): Initialize c_rdev_maj and c_rdev_min from struct stat only if the file is a device, otherwise set them to zero.
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.
2019-11-03Remove HPUX CDF supportSergey Poznyakoff1
2018-12-01Minor fixesSergey Poznyakoff1
* src/copyin.c: Remove unused variable. * src/util.c: Cast arguments to printf.
2018-12-01Fix sigfault when appending to archiveSergey Poznyakoff1
Bug reported by Ross Burton. See <http://lists.gnu.org/archive/html/bug-cpio/2018-11/msg00000.html> * src/util.c: Keep static copy of the buffer pointer; always assign it to file_hdr->c_name. Use x2realloc for memory management.
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-02-06build: lint warnings in --device-independentPavel Raiskup1
Complements: 3945f9db44c935608caa5f0 * src/util.c (find_inode_val): Drop unused variable. (get_inode_and_dev): Function doesn't return any value, drop the return value in definition.
2017-01-02Update copyright yearsSergey Poznyakoff1
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 symlink-bad-length test for 64-bit architectures.Sergey Poznyakoff1
* src/util.c: Return non-zero exit code if EOF is hit prematurely. * tests/symlink-bad-length.at: Revert to original archive: there's no use testing for recovery, because that depends on the host architecture. Don't test for exit code as well (same reason). Account for eventual warning messages.
2014-12-01New options to create device and inode-independent archives.Sergey Poznyakoff1
* src/util.c (inode_val): New member trans_inode (find_inode_val): New function. (find_inode_file): Rewrite using the above. (add_inode): Initialize the trans_inode member depending on the value of renumber_inodes_option. (get_inode_and_dev): New function. (stat_to_cpio): Use get_inode_and_dev. (arf_stores_inode_p): New function. * src/extern.h (renumber_inodes_option) (ignore_devno_option): New externs. * src/global.c (renumber_inodes_option) (ignore_devno_option): New variables. * src/main.c: Add new options. * NEWS: Document changes. * doc/cpio.1: Document new options. * doc/cpio.texi: Likewise.
2014-01-30Update copyright years.Sergey Poznyakoff1
2014-01-30Use exit codes consistenly.Sergey Poznyakoff1
2014-01-30Improve documentation.Sergey Poznyakoff1
* .gitignore: Update. * NEWS: Update. * doc/cpio.1: Rewrite. * doc/cpio.texi: Major revamp. * src/main.c (options): Fix sectioning of the help output. (parse_opt): * src/util.c: Use PAXEXIT_FAILURE to indicate an error.
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-22Minor fixes.Sergey Poznyakoff1
* src/copyout.c (count_defered_links_to_dev_ino): Return size_t. (last_link): Do not use superfluous local variable. * src/util.c (copy_files_disk_to_tape) (copy_files_disk_to_disk): Shut down gcc warnings.
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-03-10Bugfixes.Sergey Poznyakoff1
* src/main.c (cpio_options): Remove unused options. * src/util.c (cpio_create_dir): Fix conditional. * NEWS: Update.
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.
2008-02-09* NEWS, configure.ac: Raise the patchlevel number.Sergey Poznyakoff1
* THANKS: Update * doc/cpio.texi: Fix a typo. * src/extern.h (warn_if_file_changed): Fix type of the 2nd argument. * src/tar.c (write_out_tar_header): Stylistic change. * src/util.c (copy_files_disk_to_disk): Fix types of automatic variables. (warn_if_file_changed): Fix type of the 2nd argument. Patches supplied by Ladislav Michnovic.
2008-02-08UpdateSergey Poznyakoff1
2008-02-08Fix mingw build. Thanks to Robert Millan.Sergey Poznyakoff1
* NEWS, THANKS: Update. * bootstrap: Create lib/system.c, m4/sysdep.m4, update lib/system.h. * mingw.m4, sysdep.m4: New files. * configure.ac: Raise version number to 2.9.90. Call CPIO_SYSDEP. Remove the call to gl_USE_SYSTEM_EXTENSIONS. (AC_CHECK_HEADERS): Add process.h sys/ioctl.h * lib/Makefile.am (libcpio_a_SOURCES): Add system.c * src/idcache.c: Include system.h * src/userspec.c: Remove alloca stuff (already handled by gnulib). Include alloca.h. Remove useless declarations of get.* functions. * src/util.c: Include sys/ioctl.h conditionally.
2007-06-28(apply_delayed_set_stat): Use inverted permissions from data->stat.Sergey Poznyakoff1
2007-06-28(create_all_directories): Update call to make_pathSergey Poznyakoff1
(delay_set_stat,repair_delayed_set_stat) (apply_delayed_set_stat): New functions
2007-06-27Relicense under GPLv3Sergey Poznyakoff1
2007-06-08Version number 2.8Sergey Poznyakoff1
2007-06-07(set_perms): Take file descriptor as the first argument and use ↵Sergey Poznyakoff1
fchmod/fchown if available. Fixes CAN-2005-1111.
2007-06-07(set_perms, stat_to_cpio): Use CPIO_UID and CPIO_GID macros to set uid and gidSergey Poznyakoff1
2006-12-18(sparse_write): Static. Provide a forwardSergey Poznyakoff1
declaration. Define enum sparse_write_states inside the function.
2006-12-18 (tape_toss_input, warn_if_file_changed): Last argument is off_tSergey Poznyakoff1
(warn_if_file_changed): Use ngettext
2006-10-21Use STRINGIFY_BIGINT to display num_bytesSergey Poznyakoff1
2006-09-27Update copyright yearSergey Poznyakoff1
2006-07-03Use cpio_file_stat for internal header representation.Sergey Poznyakoff1
2005-10-28Include paxlib.Sergey Poznyakoff1
2005-09-08(cpio_safer_name_suffix): Preserve ./ no matter whatSergey Poznyakoff1
the value of strip_leading_dots is. (set_file_times): New function
2005-05-25(cpio_safer_name_suffix): New functionSergey Poznyakoff1
(add_cdf_double_slashes): Add FIXME warning.

Return to:

Send suggestions and report system problems to the System administrator.