-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchanges.diff
78 lines (68 loc) · 3.19 KB
/
changes.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
--- /tmp/zstd-1.5.0/build/single_file_libs/zstddeclib.c 2022-07-19 08:40:31.371785257 +0200
+++ zstddec/zstddeclib.c 2022-07-19 08:52:36.644646467 +0200
@@ -16,6 +16,13 @@
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
+
+/*
+ * findDecompressedSize interface changed from unsigned long long to U32 for wasm / browser compatibility ([email protected])
+ * further info on the issue: https://github.com/WebAssembly/WASI/issues/54
+ * This is not necessary for browsers after 2020, but there are still plenty of older devices around
+ */
+
/*
* Settings to bake for the standalone decompressor.
*
@@ -4937,7 +4944,7 @@
* note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
* read each contained frame header. This is fast as most of the data is skipped,
* however it does mean that all frame data must be present and valid. */
-ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
+ZSTDLIB_API U32 ZSTD_findDecompressedSize(const void* src, size_t srcSize);
/*! ZSTD_decompressBound() :
* `src` should point to the start of a series of ZSTD encoded and/or skippable frames
@@ -11974,17 +11981,19 @@
* `srcSize` must be the exact length of some number of ZSTD compressed and/or
* skippable frames
* @return : decompressed size of the frames contained */
-unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize)
+U32 ZSTD_findDecompressedSize(const void* src, size_t srcSize)
{
unsigned long long totalDstSize = 0;
+ U32 _error = 0xffffffff;
+
while (srcSize >= ZSTD_startingInputLength(ZSTD_f_zstd1)) {
U32 const magicNumber = MEM_readLE32(src);
if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
size_t const skippableSize = readSkippableFrameSize(src, srcSize);
if (ZSTD_isError(skippableSize)) {
- return ZSTD_CONTENTSIZE_ERROR;
+ return _error;
}
assert(skippableSize <= srcSize);
@@ -11994,15 +12003,15 @@
}
{ unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
- if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret;
+ if (ret >= ZSTD_CONTENTSIZE_ERROR) return _error;
/* check for overflow */
- if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR;
+ if (totalDstSize + ret < totalDstSize) return _error;
totalDstSize += ret;
}
{ size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize);
if (ZSTD_isError(frameSrcSize)) {
- return ZSTD_CONTENTSIZE_ERROR;
+ return _error;
}
src = (const BYTE *)src + frameSrcSize;
@@ -12010,9 +12019,9 @@
}
} /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
- if (srcSize) return ZSTD_CONTENTSIZE_ERROR;
+ if (totalDstSize >= UINT32_MAX || srcSize) return _error;
- return totalDstSize;
+ return (U32) totalDstSize;
}
/** ZSTD_getDecompressedSize() :