cpio.c (337351) | cpio.c (342360) |
---|---|
1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 28#include "cpio_platform.h" | 1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 28#include "cpio_platform.h" |
29__FBSDID("$FreeBSD: stable/11/contrib/libarchive/cpio/cpio.c 337351 2018-08-05 14:35:30Z mm $"); | 29__FBSDID("$FreeBSD: stable/11/contrib/libarchive/cpio/cpio.c 342360 2018-12-21 23:33:05Z mm $"); |
30 31#include <sys/types.h> 32#include <archive.h> 33#include <archive_entry.h> 34 35#ifdef HAVE_SYS_MKDEV_H 36#include <sys/mkdev.h> 37#endif --- 91 unchanged lines hidden (view full) --- 129 130int 131main(int argc, char *argv[]) 132{ 133 static char buff[16384]; 134 struct cpio _cpio; /* Allocated on stack. */ 135 struct cpio *cpio; 136 const char *errmsg; | 30 31#include <sys/types.h> 32#include <archive.h> 33#include <archive_entry.h> 34 35#ifdef HAVE_SYS_MKDEV_H 36#include <sys/mkdev.h> 37#endif --- 91 unchanged lines hidden (view full) --- 129 130int 131main(int argc, char *argv[]) 132{ 133 static char buff[16384]; 134 struct cpio _cpio; /* Allocated on stack. */ 135 struct cpio *cpio; 136 const char *errmsg; |
137 char *tptr; |
|
137 int uid, gid; | 138 int uid, gid; |
138 int opt; | 139 int opt, t; |
139 140 cpio = &_cpio; 141 memset(cpio, 0, sizeof(*cpio)); 142 cpio->buff = buff; 143 cpio->buff_size = sizeof(buff); 144 145#if defined(HAVE_SIGACTION) && defined(SIGPIPE) 146 { /* Ignore SIGPIPE signals. */ --- 52 unchanged lines hidden (view full) --- 199 break; 200 case 'B': /* POSIX 1997 */ 201 cpio->bytes_per_block = 5120; 202 break; 203 case OPTION_B64ENCODE: 204 cpio->add_filter = opt; 205 break; 206 case 'C': /* NetBSD/OpenBSD */ | 140 141 cpio = &_cpio; 142 memset(cpio, 0, sizeof(*cpio)); 143 cpio->buff = buff; 144 cpio->buff_size = sizeof(buff); 145 146#if defined(HAVE_SIGACTION) && defined(SIGPIPE) 147 { /* Ignore SIGPIPE signals. */ --- 52 unchanged lines hidden (view full) --- 200 break; 201 case 'B': /* POSIX 1997 */ 202 cpio->bytes_per_block = 5120; 203 break; 204 case OPTION_B64ENCODE: 205 cpio->add_filter = opt; 206 break; 207 case 'C': /* NetBSD/OpenBSD */ |
207 cpio->bytes_per_block = atoi(cpio->argument); 208 if (cpio->bytes_per_block <= 0) 209 lafe_errc(1, 0, "Invalid blocksize %s", cpio->argument); | 208 errno = 0; 209 tptr = NULL; 210 t = (int)strtol(cpio->argument, &tptr, 10); 211 if (errno || t <= 0 || *(cpio->argument) == '\0' || 212 tptr == NULL || *tptr != '\0') { 213 lafe_errc(1, 0, "Invalid blocksize: %s", 214 cpio->argument); 215 } 216 cpio->bytes_per_block = t; |
210 break; 211 case 'c': /* POSIX 1997 */ 212 cpio->format = "odc"; 213 break; 214 case 'd': /* POSIX 1997 */ 215 cpio->extract_flags &= ~ARCHIVE_EXTRACT_NO_AUTODIR; 216 break; 217 case 'E': /* NetBSD/OpenBSD */ --- 525 unchanged lines hidden (view full) --- 743 "Can't allocate path buffer"); 744 } 745 strcpy(cpio->pass_destpath, cpio->destdir); 746 strcat(cpio->pass_destpath, remove_leading_slash(srcpath)); 747 destpath = cpio->pass_destpath; 748 } 749 if (cpio->option_rename) 750 destpath = cpio_rename(destpath); | 217 break; 218 case 'c': /* POSIX 1997 */ 219 cpio->format = "odc"; 220 break; 221 case 'd': /* POSIX 1997 */ 222 cpio->extract_flags &= ~ARCHIVE_EXTRACT_NO_AUTODIR; 223 break; 224 case 'E': /* NetBSD/OpenBSD */ --- 525 unchanged lines hidden (view full) --- 750 "Can't allocate path buffer"); 751 } 752 strcpy(cpio->pass_destpath, cpio->destdir); 753 strcat(cpio->pass_destpath, remove_leading_slash(srcpath)); 754 destpath = cpio->pass_destpath; 755 } 756 if (cpio->option_rename) 757 destpath = cpio_rename(destpath); |
751 if (destpath == NULL) | 758 if (destpath == NULL) { 759 archive_entry_free(entry); |
752 return (0); | 760 return (0); |
761 } |
|
753 archive_entry_copy_pathname(entry, destpath); 754 755 /* 756 * If we're trying to preserve hardlinks, match them here. 757 */ 758 spare = NULL; 759 if (cpio->linkresolver != NULL 760 && archive_entry_filetype(entry) != AE_IFDIR) { --- 718 unchanged lines hidden --- | 762 archive_entry_copy_pathname(entry, destpath); 763 764 /* 765 * If we're trying to preserve hardlinks, match them here. 766 */ 767 spare = NULL; 768 if (cpio->linkresolver != NULL 769 && archive_entry_filetype(entry) != AE_IFDIR) { --- 718 unchanged lines hidden --- |