summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibarchive/libarchive/archive_options.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-02-20 13:04:00 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-20 13:04:00 (GMT)
commita59a7ee95601f3496ec9ba9ae1283a8d980460bf (patch)
treed8279b1fe0a6ab19eaaf6c1490040663708e192d /Utilities/cmlibarchive/libarchive/archive_options.c
parentcdce7c619c58ec0947c036b93013445bb93e4be8 (diff)
parentc206211af647dd1f7039da91c34c9c72e50aefdf (diff)
downloadCMake-a59a7ee95601f3496ec9ba9ae1283a8d980460bf.zip
CMake-a59a7ee95601f3496ec9ba9ae1283a8d980460bf.tar.gz
CMake-a59a7ee95601f3496ec9ba9ae1283a8d980460bf.tar.bz2
Merge branch 'upstream-LibArchive' into update-libarchive
* upstream-LibArchive: LibArchive 2017-02-19 (100ee75a)
Diffstat (limited to 'Utilities/cmlibarchive/libarchive/archive_options.c')
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_options.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Utilities/cmlibarchive/libarchive/archive_options.c b/Utilities/cmlibarchive/libarchive/archive_options.c
index dbf3e80..6496025 100644
--- a/Utilities/cmlibarchive/libarchive/archive_options.c
+++ b/Utilities/cmlibarchive/libarchive/archive_options.c
@@ -26,6 +26,10 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD$");
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
#include "archive_options_private.h"
static const char *
@@ -105,8 +109,11 @@ _archive_set_options(struct archive *a, const char *options,
if (options == NULL || options[0] == '\0')
return ARCHIVE_OK;
- data = (char *)malloc(strlen(options) + 1);
- strcpy(data, options);
+ if ((data = strdup(options)) == NULL) {
+ archive_set_error(a,
+ ENOMEM, "Out of memory adding file to list");
+ return (ARCHIVE_FATAL);
+ }
s = (const char *)data;
do {