Skip to content

Commit

Permalink
Fix ZipOS extraction of ZIP64 assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Mar 31, 2024
1 parent bef2cb0 commit 9ff65cf
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
16 changes: 8 additions & 8 deletions build/online.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
# - tool/build/runit.c
# - tool/build/runitd.c

.PRECIOUS: o/$(MODE)/%.com.ok
o/$(MODE)/%.com.ok: private .PLEDGE = stdio rpath wpath cpath proc fattr inet dns
o/$(MODE)/%.com.ok: private .UNVEIL += r:/etc/resolv.conf
o/$(MODE)/%.com.ok: \
o/$(MODE)/tool/build/runit.com \
o/$(MODE)/tool/build/runitd.com \
o/$(MODE)/%.com
.PRECIOUS: o/$(MODE)/%.ok
o/$(MODE)/%.ok: private .PLEDGE = stdio rpath wpath cpath proc fattr inet dns
o/$(MODE)/%.ok: private .UNVEIL += r:/etc/resolv.conf
o/$(MODE)/%.ok: \
o/$(MODE)/tool/build/runit \
o/$(MODE)/tool/build/runitd \
o/$(MODE)/%
@$(COMPILE) -wATEST -tT$@ $^ $(HOSTS)

.PHONY:
o/tiny/tool/build/runit.com:
o/tiny/tool/build/runit:
1 change: 1 addition & 0 deletions libc/nexgen32e/x86feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
#define X86_XTPR 1H, ECX, 14, 0
#define X86_ZERO_FCS_FDS 7H, EBX, 13, 0
#define X86_JIT 80000001H, ECX, 31, 0 /* IsGenuineBlink() */
#define X86_HYBRID_CPU 7H, EDX, 15, 0 /* Has performance and efficiency cores */
/* clang-format on */

/* AMD specific features */
Expand Down
8 changes: 6 additions & 2 deletions libc/str/getzipcfilecompressedsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ int64_t GetZipCfileCompressedSize(const uint8_t *z) {
const uint8_t *pe = p + ZIP_CFILE_EXTRASIZE(z);
for (; p + ZIP_EXTRA_SIZE(p) <= pe; p += ZIP_EXTRA_SIZE(p)) {
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64) {
if (8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p));
int offset = 0;
if (ZIP_CFILE_UNCOMPRESSEDSIZE(z) == 0xFFFFFFFFu) {
offset += 8;
}
if (offset + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p) + offset);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions libc/str/getzipcfileuncompressedsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ int64_t GetZipCfileUncompressedSize(const uint8_t *z) {
const uint8_t *pe = p + ZIP_CFILE_EXTRASIZE(z);
for (; p + ZIP_EXTRA_SIZE(p) <= pe; p += ZIP_EXTRA_SIZE(p)) {
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64) {
int offset = 0;
if (ZIP_CFILE_COMPRESSEDSIZE(z) == 0xFFFFFFFFu) {
offset += 8;
}
if (offset + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p) + offset);
if (8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p));
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions libc/str/getziplfilecompressedsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ int64_t GetZipLfileCompressedSize(const uint8_t *z) {
const uint8_t *pe = p + ZIP_LFILE_EXTRASIZE(z);
for (; p + ZIP_EXTRA_SIZE(p) <= pe; p += ZIP_EXTRA_SIZE(p)) {
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64) {
if (8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p));
int offset = 0;
if (ZIP_LFILE_UNCOMPRESSEDSIZE(z) == 0xFFFFFFFFu) {
offset += 8;
}
if (offset + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p) + offset);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions libc/str/getziplfileuncompressedsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ int64_t GetZipLfileUncompressedSize(const uint8_t *z) {
const uint8_t *pe = p + ZIP_LFILE_EXTRASIZE(z);
for (; p + ZIP_EXTRA_SIZE(p) <= pe; p += ZIP_EXTRA_SIZE(p)) {
if (ZIP_EXTRA_HEADERID(p) == kZipExtraZip64) {
int offset = 0;
if (ZIP_LFILE_COMPRESSEDSIZE(z) == 0xFFFFFFFFu) {
offset += 8;
}
if (offset + 8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p) + offset);
if (8 <= ZIP_EXTRA_CONTENTSIZE(p)) {
return ZIP_READ64(ZIP_EXTRA_CONTENT(p));
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions tool/emacs/cosmo-cpp-constants.el
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"__AVX5124VNNIW__"
"__AVX512VBMI__"
"__AVX512VNNI__"
"__AVX512VL__"
"__AVXVNNI__"
"__AVXVNNIINT8__"
"__AVXVNNIINT16__"
Expand Down Expand Up @@ -100,7 +101,31 @@
"__arm__"
"__aarch64__"
"__AARCH64EB__"
"__ARM_ARCH"
"__ARM_NEON"
"__ARM_FEATURE_FMA"
"__ARM_FEATURE_FP16_VECTOR_ARITHMETIC"
"__ARM_FEATURE_DOTPROD"
"__ARM_FEATURE_FRINT"
"__ARM_FEATURE_RNG"
"__ARM_FEATURE_CLZ"
"__ARM_FEATURE_CRC32"
"__ARM_FEATURE_CRYPTO"
"__ARM_FEATURE_ATOMICS"
"__ARM_FEATURE_MATMUL_INT8"
"__ARM_FEATURE_NUMERIC_MAXMIN"
"__ARM_FEATURE_QBIT"
"__ARM_FEATURE_QRDMX"
"__ARM_FEATURE_SHA2"
"__ARM_FEATURE_SHA3"
"__ARM_FEATURE_SHA512"
"__ARM_FEATURE_SM3"
"__ARM_FEATURE_SM4"
"__ARM_FEATURE_FP16_FML"
"__ARM_FP16_ARGS"
"__ARM_FP16_FORMAT_ALTERNATIVE"
"__ARM_FP16_IEEE"
"__ARM_FP_FAST"
"__powerpc__"
"__powerpc64__"
"__POWER9_VECTOR__"
Expand Down

0 comments on commit 9ff65cf

Please sign in to comment.