archive_write_set_format_pax.c (324417) | archive_write_set_format_pax.c (342360) |
---|---|
1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * Copyright (c) 2010-2012 Michihiro NAKAJIMA 4 * Copyright (c) 2016 Martin Matuska 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include "archive_platform.h" | 1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * Copyright (c) 2010-2012 Michihiro NAKAJIMA 4 * Copyright (c) 2016 Martin Matuska 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include "archive_platform.h" |
29__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_write_set_format_pax.c 324417 2017-10-08 20:54:53Z mm $"); | 29__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/archive_write_set_format_pax.c 342360 2018-12-21 23:33:05Z mm $"); |
30 31#ifdef HAVE_ERRNO_H 32#include <errno.h> 33#endif 34#ifdef HAVE_STDLIB_H 35#include <stdlib.h> 36#endif 37#ifdef HAVE_STRING_H --- 479 unchanged lines hidden (view full) --- 517 archive_set_error(&a->archive, ENOMEM, "%s %s", 518 "Can't allocate memory for ", attr); 519 return (ARCHIVE_FATAL); 520 } 521 archive_set_error(&a->archive, 522 ARCHIVE_ERRNO_FILE_FORMAT, "%s %s %s", 523 "Can't translate ", attr, " to UTF-8"); 524 return(ARCHIVE_WARN); | 30 31#ifdef HAVE_ERRNO_H 32#include <errno.h> 33#endif 34#ifdef HAVE_STDLIB_H 35#include <stdlib.h> 36#endif 37#ifdef HAVE_STRING_H --- 479 unchanged lines hidden (view full) --- 517 archive_set_error(&a->archive, ENOMEM, "%s %s", 518 "Can't allocate memory for ", attr); 519 return (ARCHIVE_FATAL); 520 } 521 archive_set_error(&a->archive, 522 ARCHIVE_ERRNO_FILE_FORMAT, "%s %s %s", 523 "Can't translate ", attr, " to UTF-8"); 524 return(ARCHIVE_WARN); |
525 } else if (*p != '\0') { | 525 } 526 527 if (*p != '\0') { |
526 add_pax_attr(&(pax->pax_header), 527 attr, p); | 528 add_pax_attr(&(pax->pax_header), 529 attr, p); |
528 free(p); | |
529 } | 530 } |
531 free(p); |
|
530 return(ARCHIVE_OK); 531} 532 533/* 534 * TODO: Consider adding 'comment' and 'charset' fields to 535 * archive_entry so that clients can specify them. Also, consider 536 * adding generic key/value tags so clients can add arbitrary 537 * key/value data. --- 117 unchanged lines hidden (view full) --- 655 } else 656#endif 657 p = archive_entry_pathname(entry_original); 658 /* 659 * On Windows, this is a backup operation just in 660 * case getting WCS failed. On POSIX, this is a 661 * normal operation. 662 */ | 532 return(ARCHIVE_OK); 533} 534 535/* 536 * TODO: Consider adding 'comment' and 'charset' fields to 537 * archive_entry so that clients can specify them. Also, consider 538 * adding generic key/value tags so clients can add arbitrary 539 * key/value data. --- 117 unchanged lines hidden (view full) --- 657 } else 658#endif 659 p = archive_entry_pathname(entry_original); 660 /* 661 * On Windows, this is a backup operation just in 662 * case getting WCS failed. On POSIX, this is a 663 * normal operation. 664 */ |
663 if (p != NULL && p[strlen(p) - 1] != '/') { | 665 if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') { |
664 struct archive_string as; 665 666 archive_string_init(&as); 667 path_length = strlen(p); 668 if (archive_string_ensure(&as, 669 path_length + 2) == NULL) { 670 archive_set_error(&a->archive, ENOMEM, 671 "Can't allocate pax data"); --- 1298 unchanged lines hidden --- | 666 struct archive_string as; 667 668 archive_string_init(&as); 669 path_length = strlen(p); 670 if (archive_string_ensure(&as, 671 path_length + 2) == NULL) { 672 archive_set_error(&a->archive, ENOMEM, 673 "Can't allocate pax data"); --- 1298 unchanged lines hidden --- |