Commit 156cb3bb authored by Brad King's avatar Brad King

Merge branch 'libarchive-upstream' into update-libarchive

Conflicts:
	Utilities/cmlibarchive/CMakeLists.txt
	Utilities/cmlibarchive/libarchive/archive_windows.c
parents fd42bf1b 4f4fe6e5
......@@ -2,7 +2,7 @@
#
PROJECT(libarchive C)
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin)
......@@ -37,9 +37,10 @@ SET(LIBARCHIVE_VERSION_STRING "${VERSION}")
# INTERFACE_VERSION increments with every release
# libarchive 2.7 == interface version 9 = 2 + 7
# libarchive 2.8 == interface version 10 = 2 + 8
# libarchive 3.0 == interface version 11
# libarchive 3.x == interface version 11 + x
math(EXPR INTERFACE_VERSION "11 + ${_minor}")
# libarchive 2.9 == interface version 11 = 2 + 9
# libarchive 3.0 == interface version 12
# libarchive 3.x == interface version 12 + x
math(EXPR INTERFACE_VERSION "12 + ${_minor}")
# Set SOVERSION == Interface version
# ?? Should there be more here ??
......@@ -58,10 +59,6 @@ ENDIF()
# Enable CTest/CDash support
include(CTest)
# Provide ADD_TEST_28 macro to approximate CMake 2.8 ADD_TEST(NAME).
# TODO: Require CMake 2.8 and drop this workaround (perhaps late 2010).
INCLUDE(AddTest28)
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
......
# - Macro approximating the CMake 2.8 ADD_TEST(NAME) signature.
# ADD_TEST_28(NAME <name> COMMAND <command> [arg1 [arg2 ...]])
# <name> - The name of the test
# <command> - The test executable
# [argN...] - Arguments to the test executable
# This macro approximates the ADD_TEST(NAME) signature provided in
# CMake 2.8 but works with CMake 2.6 too. See CMake 2.8 documentation
# of ADD_TEST()for details.
#
# This macro automatically replaces a <command> that names an
# executable target with the target location. A generator expression
# of the form "$<TARGET_FILE:tgt>" is supported in both the command
# and arguments of the test. Howerver, this macro only works for
# targets without per-config output name properties set.
#
# Example usage:
# add_test(NAME mytest COMMAND testDriver --exe $<TARGET_FILE:myexe>)
# This creates a test "mytest" whose command runs a testDriver tool
# passing the full path to the executable file produced by target
# "myexe".
#=============================================================================
# Copyright 2009 Kitware, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer
# in this position and unchanged.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
# CMake 2.8 supports ADD_TEST(NAME) natively.
IF(NOT "${CMAKE_VERSION}" VERSION_LESS "2.8")
MACRO(ADD_TEST_28)
ADD_TEST(${ARGV})
ENDMACRO()
RETURN()
ENDIF()
# Simulate ADD_TEST(NAME) signature from CMake 2.8.
MACRO(ADD_TEST_28 NAME name COMMAND command)
# Enforce the signature.
IF(NOT "x${NAME}" STREQUAL "xNAME")
MESSAGE(FATAL_ERROR "First ADD_TEST_28 argument must be \"NAME\"")
ENDIF()
IF(NOT "x${COMMAND}" STREQUAL "xCOMMAND")
MESSAGE(FATAL_ERROR "Third ADD_TEST_28 argument must be \"COMMAND\"")
ENDIF()
# Perform "COMMAND myexe ..." substitution.
SET(cmd "${command}")
IF(TARGET "${cmd}")
_ADD_TEST_28_GET_EXE(${cmd} cmd)
ENDIF()
# Perform "COMMAND ... $<TARGET_FILE:myexe> ..." substitution.
SET(target_file "\\$<TARGET_FILE:(.+)>")
SET(args)
FOREACH(ARG ${cmd} ${ARGN})
SET(arg "${ARG}")
IF("${arg}" MATCHES "${target_file}")
STRING(REGEX REPLACE "${target_file}" "\\1" tgt "${arg}")
IF(TARGET "${tgt}")
_ADD_TEST_28_GET_EXE(${tgt} exe)
STRING(REGEX REPLACE "${target_file}" "${exe}" arg "${arg}")
ENDIF()
ENDIF()
LIST(APPEND args "${arg}")
ENDFOREACH()
# Invoke old ADD_TEST() signature with transformed arguments.
ADD_TEST(${name} ${args})
ENDMACRO()
# Get the test-time location of an executable target.
MACRO(_ADD_TEST_28_GET_EXE tgt exe_var)
# The LOCATION property gives a build-time location.
GET_TARGET_PROPERTY(${exe_var} ${tgt} LOCATION)
# In single-configuration generatrs the build-time and test-time
# locations are the same because there is no per-config variable
# reference. In multi-configuration generators the following
# substitution converts the build-time configuration variable
# reference to a test-time configuration variable reference.
IF(CMAKE_CONFIGURATION_TYPES)
STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CTEST_CONFIGURATION_TYPE}"
${exe_var} "${${exe_var}}")
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDMACRO()
......@@ -131,27 +131,16 @@ extern "C" {
* easy to compare versions at build time: for version a.b.c, the
* version number is printf("%d%03d%03d",a,b,c). For example, if you
* know your application requires version 2.12.108 or later, you can
* assert that ARCHIVE_VERSION >= 2012108.
*
* This single-number format was introduced with libarchive 1.9.0 in
* the libarchive 1.x family and libarchive 2.2.4 in the libarchive
* 2.x family. The following may be useful if you really want to do
* feature detection for earlier libarchive versions (which defined
* ARCHIVE_API_VERSION and ARCHIVE_API_FEATURE instead):
*
* #ifndef ARCHIVE_VERSION_NUMBER
* #define ARCHIVE_VERSION_NUMBER \
* (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
* #endif
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3000001
#define ARCHIVE_VERSION_NUMBER 3000002
__LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_STRING "libarchive 3.0.1b"
#define ARCHIVE_VERSION_STRING "libarchive 3.0.2"
__LA_DECL const char * archive_version_string(void);
/* Declare our basic types. */
......@@ -454,8 +443,6 @@ __LA_DECL int archive_read_data_block(struct archive *a,
* 'into_fd': writes data to specified filedes
*/
__LA_DECL int archive_read_data_skip(struct archive *);
__LA_DECL int archive_read_data_into_buffer(struct archive *,
void *buffer, __LA_SSIZE_T len);
__LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
/*
......
......@@ -26,7 +26,7 @@
.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.18 2008/05/26 17:00:22 kientzle Exp $
.\"
.Dd Feburary 22, 2010
.Dt archive_entry 3
.Dt ARCHIVE_ENTRY 3
.Os
.Sh NAME
.Nm archive_entry_clear ,
......
......@@ -29,7 +29,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3000001
#define ARCHIVE_VERSION_NUMBER 3000002
/*
* Note: archive_entry.h is for use outside of libarchive; the
......
......@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.Dd February 21, 2010
.Dt archive_entry_acl 3
.Dt ARCHIVE_ENTRY_ACL 3
.Os
.Sh NAME
.Nm archive_entry_acl_add_entry ,
......
......@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.Dd February 20, 2010
.Dt archive_entry_linkify 3
.Dt ARCHIVE_ENTRY_LINKIFY 3
.Os
.Sh NAME
.Nm archive_entry_linkresolver ,
......
......@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.Dd February 22, 2010
.Dt archive_entry_paths 3
.Dt ARCHIVE_ENTRY_PATHS 3
.Os
.Sh NAME
.Nm archive_entry_hardlink ,
......
......@@ -24,7 +24,7 @@
.\" SUCH DAMAGE.
.\"
.Dd February 22, 2010
.Dt archive_entry_perms 3
.Dt ARCHIVE_ENTRY_PERMS 3
.Os
.Sh NAME
.Nm archive_entry_gid ,
......
......@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.Dd May 12, 2008
.Dt archive_entry 3
.Dt ARCHIVE_ENTRY 3
.Os
.Sh NAME
.Nm archive_entry_stat ,
......
......@@ -26,7 +26,7 @@
.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.18 2008/05/26 17:00:22 kientzle Exp $
.\"
.Dd February 21, 2010
.Dt archive_entry_time 3
.Dt ARCHIVE_ENTRY_TIME 3
.Os
.Sh NAME
.Nm archive_entry_atime ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
.Dd March 23, 2011
.Dt archive_read 3
.Dt ARCHIVE_READ 3
.Os
.Sh NAME
.Nm archive_read
......
......@@ -668,22 +668,6 @@ archive_read_data(struct archive *_a, void *buff, size_t s)
return (bytes_read);
}
#if ARCHIVE_API_VERSION < 3
/*
* Obsolete function provided for compatibility only. Note that the API
* of this function doesn't allow the caller to detect if the remaining
* data from the archive entry is shorter than the buffer provided, or
* even if an error occurred while reading data.
*/
int
archive_read_data_into_buffer(struct archive *a, void *d, ssize_t len)
{
archive_read_data(a, d, len);
return (ARCHIVE_OK);
}
#endif
/*
* Skip over all remaining data in this entry.
*/
......
......@@ -25,15 +25,12 @@
.\" $FreeBSD$
.\"
.Dd March 22, 2011
.Dt archive_read_data 3
.Dt ARCHIVE_READ_DATA 3
.Os
.Sh NAME
.Nm archive_read_data
.Nm archive_read_data_block ,
.Nm archive_read_data_skip ,
.\" #if ARCHIVE_API_VERSION < 3
.Nm archive_read_data_into_buffer ,
.\" #endif
.Nm archive_read_data_into_fd
.Nd functions for reading streaming archives
.Sh SYNOPSIS
......@@ -49,10 +46,6 @@
.Fc
.Ft int
.Fn archive_read_data_skip "struct archive *"
.\" #if ARCHIVE_API_VERSION < 3
.Ft int
.Fn archive_read_data_into_buffer "struct archive *" "void *" "ssize_t len"
.\" #endif
.Ft int
.Fn archive_read_data_into_fd "struct archive *" "int fd"
.\"
......@@ -84,13 +77,6 @@ to skip all of the data for this archive entry.
Note that this function is invoked automatically by
.Fn archive_read_next_header2
if the previous entry was not completely consumed.
.\" #if ARCHIVE_API_VERSION < 3
.It Fn archive_read_data_into_buffer
This function is deprecated and will be removed.
Use
.Fn archive_read_data
instead.
.\" #endif
.It Fn archive_read_data_into_fd
A convenience function that repeatedly calls
.Fn archive_read_data_block
......
......@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_data_into_fd.c,v 1.16 2008/0
/*
* This implementation minimizes copying of data and is sparse-file aware.
*/
int
static int
pad_to(struct archive *a, int fd, int can_lseek,
size_t nulls_size, const char *nulls,
int64_t target_offset, int64_t actual_offset)
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_read_disk.3 190957 2009-04-12 05:04:02Z kientzle $
.\"
.Dd March 10, 2009
.Dt archive_read_disk 3
.Dt ARCHIVE_READ_DISK 3
.Os
.Sh NAME
.Nm archive_read_disk_new ,
......@@ -283,7 +283,7 @@ and first appeared in
The
.Nm libarchive
library was written by
.An Tim Kientzle Aq kientzle@freebsd.org .
.An Tim Kientzle Aq kientzle@FreeBSD.org .
.Sh BUGS
The
.Dq standard
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD$
.\"
.Dd March 22, 2011
.Dt archive_read_extract 3
.Dt ARCHIVE_READ_EXTRACT 3
.Os
.Sh NAME
.Nm archive_read_extract ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD$
.\"
.Dd March 19, 2011
.Dt archive_read_filter 3
.Dt ARCHIVE_READ_FILTER 3
.Os
.Sh NAME
.Nm archive_read_support_filter_all ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
.Dd March 19, 2011
.Dt archive_read_format 3
.Dt ARCHIVE_READ_FORMAT 3
.Os
.Sh NAME
.Nm archive_read_support_format_7zip ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
.Dd March 20, 2011
.Dt archive_read_free 3
.Dt ARCHIVE_READ_FREE 3
.Os
.Sh NAME
.Nm archive_read_close ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD$
.\"
.Dd March 22, 2011
.Dt archive_read_header 3
.Dt ARCHIVE_READ_HEADER 3
.Os
.Sh NAME
.Nm archive_read_next_header ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
.Dd March 20, 2011
.Dt archive_read_new 3
.Dt ARCHIVE_READ_NEW 3
.Os
.Sh NAME
.Nm archive_read_new
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
.Dd March 19, 2011
.Dt archive_read_open 3
.Dt ARCHIVE_READ_OPEN 3
.Os
.Sh NAME
.Nm archive_read_open ,
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD$
.\"
.Dd April 13, 2009
.Dt archive_read_options 3
.Dt ARCHIVE_READ_OPTIONS 3
.Os
.Sh NAME
.Nm archive_read_set_filter_option ,
......
......@@ -1962,7 +1962,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
(parent->re || parent->re_descendant))
file->re_descendant = 1;
if (file->cl_offset) {
struct file_info *p;
struct file_info *r;
if (parent == NULL || parent->parent == NULL) {
archive_set_error(&a->archive,
......@@ -1990,8 +1990,8 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
* Sanity check: cl_offset does not point at its
* the parents or itself.
*/
for (p = parent; p; p = p->parent) {
if (p->offset == file->cl_offset) {
for (r = parent; r; r = r->parent) {
if (r->offset == file->cl_offset) {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge CL");
......
......@@ -112,6 +112,8 @@ struct zip {
};
#define ZIP_LENGTH_AT_END 8
#define ZIP_ENCRYPTED (1<<0)
#define ZIP_STRONG_ENCRYPTED (1<<6)
#define ZIP_UTF8_NAME (1<<11)
static int archive_read_format_zip_streamable_bid(struct archive_read *, int);
......@@ -356,7 +358,32 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a,
typically faster (easier for I/O layer to optimize). */
__archive_read_seek(a, zip->entry->local_header_offset, SEEK_SET);
zip->unconsumed = 0;
return zip_read_local_file_header(a, entry, zip);
r = zip_read_local_file_header(a, entry, zip);
if (r != ARCHIVE_OK)
return r;
if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) {
const void *p;
size_t linkname_length = archive_entry_size(entry);
archive_entry_set_size(entry, 0);
p = __archive_read_ahead(a, linkname_length, NULL);
if (p == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Truncated Zip file");
return ARCHIVE_FATAL;
}
if (archive_entry_copy_symlink_l(entry, p, linkname_length,
NULL) != 0) {
/* NOTE: If the last argument is NULL, this will
* fail only by memeory allocation failure. */
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory for Symlink");
return (ARCHIVE_FATAL);
}
/* TODO: handle character-set issues? */
}
return ARCHIVE_OK;
}
static int
......@@ -722,6 +749,12 @@ archive_read_format_zip_read_data(struct archive_read *a,
if (AE_IFREG != (zip->entry->mode & AE_IFMT))
return (ARCHIVE_EOF);
if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Encrypted file is unsupported");
return (ARCHIVE_FAILED);
}
__archive_read_consume(a, zip->unconsumed);
zip->unconsumed = 0;
......
......@@ -212,7 +212,7 @@ static struct archive_string *
archive_string_append(struct archive_string *as, const char *p, size_t s)
{
if (archive_string_ensure(as, as->length + s + 1) == NULL)
__archive_errx(1, "Out of memory");
return (NULL);
memcpy(as->s + as->length, p, s);
as->length += s;
as->s[as->length] = 0;
......@@ -223,7 +223,7 @@ static struct archive_wstring *
archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s)
{
if (archive_wstring_ensure(as, as->length + s + 1) == NULL)
__archive_errx(1, "Out of memory");
return (NULL);
wmemcpy(as->s + as->length, p, s);
as->length += s;
as->s[as->length] = 0;
......@@ -233,13 +233,15 @@ archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s)
void
archive_string_concat(struct archive_string *dest, struct archive_string *src)
{
archive_string_append(dest, src->s, src->length);
if (archive_string_append(dest, src->s, src->length) == NULL)
__archive_errx(1, "Out of memory");
}
void
archive_wstring_concat(struct archive_wstring *dest, struct archive_wstring *src)
{
archive_wstring_append(dest, src->s, src->length);
if (archive_wstring_append(dest, src->s, src->length) == NULL)
__archive_errx(1, "Out of memory");
}
void
......@@ -346,7 +348,9 @@ archive_strncat(struct archive_string *as, const void *_p, size_t n)
pp++;
s++;
}
return (archive_string_append(as, p, s));
if ((as = archive_string_append(as, p, s)) == NULL)
__archive_errx(1, "Out of memory");
return (as);
}
struct archive_wstring *
......@@ -362,7 +366,9 @@ archive_wstrncat(struct archive_wstring *as, const wchar_t *p, size_t n)
pp++;
s++;
}
return (archive_wstring_append(as, p, s));
if ((as = archive_wstring_append(as, p, s)) == NULL)
__archive_errx(1, "Out of memory");
return (as);
}
struct archive_string *
......@@ -387,13 +393,17 @@ archive_wstrcat(struct archive_wstring *as, const wchar_t *p)
struct archive_string *
archive_strappend_char(struct archive_string *as, char c)
{
return (archive_string_append(as, &c, 1));
if ((as = archive_string_append(as, &c, 1)) == NULL)
__archive_errx(1, "Out of memory");
return (as);
}
struct archive_wstring *
archive_wstrappend_wchar(struct archive_wstring *as, wchar_t c)
{
return (archive_wstring_append(as, &c, 1));
if ((as = archive_wstring_append(as, &c, 1)) == NULL)
__archive_errx(1, "Out of memory");
return (as);
}
/*
......@@ -2080,14 +2090,8 @@ archive_strncat_in_locale(struct archive_string *as, const void *_p, size_t n,
*/
if (sc == NULL) {
length = mbsnbytes(_p, n);
/*
* archive_string_append() will call archive_string_ensure()
* but we cannot know if that call is failed or not. so
* we call archive_string_ensure() here.
*/
if (archive_string_ensure(as, as->length + length + 1) == NULL)
return (-1);
archive_string_append(as, _p, length);
if (archive_string_append(as, _p, length) == NULL)
return (-1);/* No memory */
return (0);
}
......@@ -2338,7 +2342,8 @@ best_effort_strncat_in_locale(struct archive_string *as, const void *_p,
* And then this checks all copied MBS can be WCS if so returns 0.
*/
if (sc->same) {
archive_string_append(as, _p, length);
if (archive_string_append(as, _p, length) == NULL)
return (-1);/* No memory */
return (invalid_mbs(_p, length, sc));
}
......@@ -4115,10 +4120,14 @@ archive_mstring_copy_mbs_len_l(struct archive_mstring *aes,
* characters because Windows platform cannot make locale UTF-8.
*/
if (sc == NULL) {
archive_string_append(&(aes->aes_mbs),
mbs, mbsnbytes(mbs, len));
aes->aes_set = AES_SET_MBS;
r = 0;
if (archive_string_append(&(aes->aes_mbs),
mbs, mbsnbytes(mbs, len)) == NULL) {
aes->aes_set = 0;
r = -1;
} else {
aes->aes_set = AES_SET_MBS;
r = 0;
}
#if defined(HAVE_ICONV)
} else if (sc != NULL && sc->cd_w != (iconv_t)-1) {
/*
......
......@@ -25,7 +25,7 @@
.\" $FreeBSD: head/lib/libarchive/archive_util.3 201098 2009-12-28 02:58:14Z kientzle $
.\"
.Dd January 8, 2005
.Dt archive_util 3
.Dt ARCHIVE_UTIL 3
.Os
.Sh NAME
.Nm archive_clear_error ,
......
......@@ -152,6 +152,11 @@ __la_win_permissive_name_w(const wchar_t *wname)
l = GetFullPathNameW(wname, 0, NULL, NULL);
if (l == 0)
return (NULL);
/* NOTE: GetFullPathNameW has a bug that if the length of the file
* name is just one that return imcomplete buffer size. Thus, we
* have to add three to the size to allocate a sufficient buffer
* size for the full-pathname of the file name. */
l += 3;
wnp = malloc(l * sizeof(wchar_t));
if (wnp == NULL)
return (NULL);
......@@ -246,27 +251,6 @@ la_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
return (handle);
}
/*
* This fcntl is limited implementation.
*/
int
__la_fcntl(int fd, int cmd, int val)
{
HANDLE handle;
handle = (HANDLE)_get_osfhandle(fd);
if (GetFileType(handle) == FILE_TYPE_PIPE) {
if (cmd == F_SETFL && val == 0) {
DWORD mode = PIPE_WAIT;
if (SetNamedPipeHandleState(
handle, &mode, NULL, NULL) != 0)
return (0);
}
}
errno = EINVAL;
return (-1);
}
#if defined(__LA_LSEEK_NEEDED)
__int64
__la_lseek(int fd, __int64 offset, int whence)
......@@ -419,22 +403,6 @@ __la_read(int fd, void *buf, size_t nbytes)
if (nbytes == 0)
return (0);
handle = (HANDLE)_get_osfhandle(fd);
if (GetFileType(handle) == FILE_TYPE_PIPE) {
DWORD sta;
if (GetNamedPipeHandleState(
handle, &sta, NULL, NULL, NULL, NULL, 0) != 0 &&
(sta & PIPE_NOWAIT) == 0) {
DWORD avail = -1;
int cnt = 3;