Run a virtual iPhone on an Apple Silicon Mac.
Swift
Harden libarchive extraction: secure flags for path traversal, NULL pathname guard
Lakref02d502447e
diff --git a/scripts/vphoned/unarchive.m b/scripts/vphoned/unarchive.mindex 78a5fb99..cbd448c2 100644--- a/scripts/vphoned/unarchive.m+++ b/scripts/vphoned/unarchive.m@@ -24,7 +24,10 @@ int vp_extract_archive(NSString *archivePath, NSString *extractionPath) {int flags = ARCHIVE_EXTRACT_TIME| ARCHIVE_EXTRACT_PERM| ARCHIVE_EXTRACT_ACL- | ARCHIVE_EXTRACT_FFLAGS;+ | ARCHIVE_EXTRACT_FFLAGS+ | ARCHIVE_EXTRACT_SECURE_SYMLINKS+ | ARCHIVE_EXTRACT_SECURE_NODOTDOT+ | ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;struct archive *a = archive_read_new();archive_read_support_format_all(a);@@ -48,7 +51,10 @@ int vp_extract_archive(NSString *archivePath, NSString *extractionPath) {fprintf(stderr, "%s\n", archive_error_string(a));if (r < ARCHIVE_WARN) { ret = 1; goto cleanup; }- NSString *currentFile = [NSString stringWithUTF8String:archive_entry_pathname(entry)];+ const char *entryPath = archive_entry_pathname(entry);+ if (!entryPath) { ret = 1; goto cleanup; }+ NSString *currentFile = [NSString stringWithUTF8String:entryPath];+ if (!currentFile) { ret = 1; goto cleanup; }NSString *fullOutputPath = [extractionPath stringByAppendingPathComponent:currentFile];archive_entry_set_pathname(entry, fullOutputPath.fileSystemRepresentation);diff --git a/scripts/vphoned/vendor/libarchive/archive.h b/scripts/vphoned/vendor/libarchive/archive.hindex af0c4643..f52740ea 100644--- a/scripts/vphoned/vendor/libarchive/archive.h+++ b/scripts/vphoned/vendor/libarchive/archive.h@@ -48,10 +48,13 @@ struct archive_entry;#define ARCHIVE_WARN (-20)/* Extract flags */-#define ARCHIVE_EXTRACT_TIME 0x0004-#define ARCHIVE_EXTRACT_PERM 0x0002-#define ARCHIVE_EXTRACT_ACL 0x0020-#define ARCHIVE_EXTRACT_FFLAGS 0x0040+#define ARCHIVE_EXTRACT_TIME 0x0004+#define ARCHIVE_EXTRACT_PERM 0x0002+#define ARCHIVE_EXTRACT_ACL 0x0020+#define ARCHIVE_EXTRACT_FFLAGS 0x0040+#define ARCHIVE_EXTRACT_SECURE_SYMLINKS 0x0100+#define ARCHIVE_EXTRACT_SECURE_NODOTDOT 0x0200+#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS 0x10000/* Error string */const char *archive_error_string(struct archive *);