task_id
stringlengths 30
61
| workdir
stringclasses 1
value | project_name
stringclasses 32
values | tag_name
stringlengths 19
32
| report_path
stringlengths 53
84
| vulnerability_description
stringlengths 76
116
| patch_diff
stringlengths 375
461k
|
|---|---|---|---|---|---|---|
3rdn4/assimp:0422dff-heap_buffer_overflow
|
/workspace/skyset/
|
assimp
|
0422dff-heap_buffer_overflow
|
/workspace/skyset/assimp/0422dff-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/assimp/0422dff-heap_buffer_overflow/immutable/
|
From d5294be00b0f89486b3459d5835045dbf26444b5 Mon Sep 17 00:00:00 2001
From: Alex <[email protected]>
Date: Sat, 10 Dec 2022 01:22:00 +0000
Subject: [PATCH] Fixes Heap-buffer-overflow READ 4 in
Assimp::ScenePreprocessor::ProcessMesh
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49797
---
code/AssetLib/OFF/OFFLoader.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/code/AssetLib/OFF/OFFLoader.cpp b/code/AssetLib/OFF/OFFLoader.cpp
index a366d74633..cb265029a0 100644
--- a/code/AssetLib/OFF/OFFLoader.cpp
+++ b/code/AssetLib/OFF/OFFLoader.cpp
@@ -290,11 +290,12 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
sz = line; SkipSpaces(&sz);
idx = strtoul10(sz,&sz);
if(!idx || idx > 9) {
- ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
+ ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
--mesh->mNumFaces;
+ ++i;
continue;
- }
- faces->mNumIndices = idx;
+ }
+ faces->mNumIndices = idx;
faces->mIndices = new unsigned int[faces->mNumIndices];
for (unsigned int m = 0; m < faces->mNumIndices;++m) {
SkipSpaces(&sz);
|
3rdn4/assimp:2d44861-unknown_write
|
/workspace/skyset/
|
assimp
|
2d44861-unknown_write
|
/workspace/skyset/assimp/2d44861-unknown_write/report.txt
|
A unknown write found in /workspace/skyset/assimp/2d44861-unknown_write/immutable/
|
From 36dfa3bed31fe220a15648083a78c925fbec0792 Mon Sep 17 00:00:00 2001
From: Alex <[email protected]>
Date: Wed, 14 Jun 2023 15:50:50 +0000
Subject: [PATCH] Fix UNKNOWN WRITE in Assimp::SortByPTypeProcess::Execute
---
code/AssetLib/OFF/OFFLoader.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/AssetLib/OFF/OFFLoader.cpp b/code/AssetLib/OFF/OFFLoader.cpp
index cb265029a0..f50afb57ba 100644
--- a/code/AssetLib/OFF/OFFLoader.cpp
+++ b/code/AssetLib/OFF/OFFLoader.cpp
@@ -284,7 +284,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
for (unsigned int i = 0; i < numFaces; ) {
if(!GetNextLine(buffer,line)) {
ASSIMP_LOG_ERROR("OFF: The number of faces in the header is incorrect");
- break;
+ throw DeadlyImportError("OFF: The number of faces in the header is incorrect");
}
unsigned int idx;
sz = line; SkipSpaces(&sz);
|
3rdn4/c-blosc:01df770-heap_buffer_overflow
|
/workspace/skyset/
|
c-blosc
|
01df770-heap_buffer_overflow
|
/workspace/skyset/c-blosc/01df770-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/c-blosc/01df770-heap_buffer_overflow/immutable/
|
From e3fdd3e506a23ec66d9f3fe2fe346e4a03b1787a Mon Sep 17 00:00:00 2001
From: Francesc Alted <[email protected]>
Date: Fri, 3 Jul 2020 11:03:31 +0200
Subject: [PATCH] blosclz updated to 2.3.0 (backport from c-blosc2)
---
blosc/blosc.h | 8 +-
blosc/blosclz.c | 467 ++++++++++++++++++++++++++++++++++--------------
2 files changed, 341 insertions(+), 134 deletions(-)
diff --git a/blosc/blosc.h b/blosc/blosc.h
index b5e44b42..3d38ab99 100644
--- a/blosc/blosc.h
+++ b/blosc/blosc.h
@@ -18,14 +18,14 @@ extern "C" {
/* Version numbers */
#define BLOSC_VERSION_MAJOR 1 /* for major interface/format changes */
-#define BLOSC_VERSION_MINOR 19 /* for minor interface/format changes */
+#define BLOSC_VERSION_MINOR 20 /* for minor interface/format changes */
#define BLOSC_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */
-#define BLOSC_VERSION_STRING "1.19.1.dev" /* string version. Sync with above! */
+#define BLOSC_VERSION_STRING "1.20.0.dev" /* string version. Sync with above! */
#define BLOSC_VERSION_REVISION "$Rev$" /* revision version */
-#define BLOSC_VERSION_DATE "$Date:: 2020-06-05 #$" /* date version */
+#define BLOSC_VERSION_DATE "$Date:: 2020-07-03 #$" /* date version */
-#define BLOSCLZ_VERSION_STRING "2.2.0" /* the internal compressor version */
+#define BLOSCLZ_VERSION_STRING "2.3.0" /* the internal compressor version */
/* The *_FORMAT symbols should be just 1-byte long */
#define BLOSC_VERSION_FORMAT 2 /* Blosc format version, starting at 1 */
diff --git a/blosc/blosclz.c b/blosc/blosclz.c
index 602ff31a..752b898c 100644
--- a/blosc/blosclz.c
+++ b/blosc/blosclz.c
@@ -14,6 +14,7 @@
#include <stdio.h>
+#include <stdbool.h>
#include "blosclz.h"
#include "fastcopy.h"
#include "blosc-common.h"
@@ -23,11 +24,11 @@
* Give hints to the compiler for branch prediction optimization.
*/
#if defined(__GNUC__) && (__GNUC__ > 2)
-#define BLOSCLZ_EXPECT_CONDITIONAL(c) (__builtin_expect((c), 1))
-#define BLOSCLZ_UNEXPECT_CONDITIONAL(c) (__builtin_expect((c), 0))
+#define BLOSCLZ_LIKELY(c) (__builtin_expect((c), 1))
+#define BLOSCLZ_UNLIKELY(c) (__builtin_expect((c), 0))
#else
-#define BLOSCLZ_EXPECT_CONDITIONAL(c) (c)
-#define BLOSCLZ_UNEXPECT_CONDITIONAL(c) (c)
+#define BLOSCLZ_LIKELY(c) (c)
+#define BLOSCLZ_UNLIKELY(c) (c)
#endif
/*
@@ -49,26 +50,14 @@
#define BLOSCLZ_READU32(p) *((const uint32_t*)(p))
#endif
-#define HASH_LOG (12)
+#define HASH_LOG (12U)
// This is used in LZ4 and seems to work pretty well here too
-#define HASH_FUNCTION(v, s, h) { \
- v = (s * 2654435761U) >> (32U - h); \
+#define HASH_FUNCTION(v, s, h) { \
+ v = (s * 2654435761U) >> (32U - h); \
}
-#define LITERAL(ip, op, op_limit, anchor, copy) { \
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(op + 2 > op_limit)) \
- goto out; \
- *op++ = *anchor++; \
- ip = anchor; \
- copy++; \
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(copy == MAX_COPY)) { \
- copy = 0; \
- *op++ = MAX_COPY-1; \
- } \
-}
-
#if defined(__AVX2__)
static uint8_t *get_run_32(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref) {
uint8_t x = ip[-1];
@@ -175,6 +164,7 @@ static uint8_t *get_run_16(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *
}
#else
+
static uint8_t *get_run(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref) {
uint8_t x = ip[-1];
int64_t value, value2;
@@ -201,6 +191,7 @@ static uint8_t *get_run(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref
while ((ip < ip_bound) && (*ref++ == x)) ip++;
return ip;
}
+
#endif
@@ -308,6 +299,213 @@ static uint8_t *get_match_32(uint8_t *ip, const uint8_t *ip_bound, const uint8_t
#endif
+static uint8_t* get_run_or_match(uint8_t* ip, uint8_t* ip_bound, const uint8_t* ref, bool run) {
+ if (BLOSCLZ_UNLIKELY(run)) {
+#if defined(__AVX2__)
+ ip = get_run_32(ip, ip_bound, ref);
+#elif defined(__SSE2__)
+ ip = get_run_16(ip, ip_bound, ref);
+#else
+ ip = get_run(ip, ip_bound, ref);
+#endif
+ }
+ else {
+#if defined(__AVX2__)
+ ip = get_match_32(ip, ip_bound, ref);
+#elif defined(__SSE2__)
+ ip = get_match_16(ip, ip_bound, ref);
+#else
+ ip = get_match(ip, ip_bound, ref);
+#endif
+ }
+
+ return ip;
+}
+
+
+#define LITERAL(ip, op, op_limit, anchor, copy) { \
+ if (BLOSCLZ_UNLIKELY(op + 2 > op_limit)) \
+ goto out; \
+ *op++ = *anchor++; \
+ ip = anchor; \
+ copy++; \
+ if (BLOSCLZ_UNLIKELY(copy == MAX_COPY)) { \
+ copy = 0; \
+ *op++ = MAX_COPY-1; \
+ } \
+}
+
+#define LITERAL2(ip, oc, anchor, copy) { \
+ oc++; anchor++; \
+ ip = anchor; \
+ copy++; \
+ if (BLOSCLZ_UNLIKELY(copy == MAX_COPY)) { \
+ copy = 0; \
+ oc++; \
+ } \
+}
+
+#define DISTANCE_SHORT(op, op_limit, len, distance) { \
+ if (BLOSCLZ_UNLIKELY(op + 2 > op_limit)) \
+ goto out; \
+ *op++ = (uint8_t)((len << 5U) + (distance >> 8U)); \
+ *op++ = (uint8_t)((distance & 255U)); \
+}
+
+#define DISTANCE_LONG(op, op_limit, len, distance) { \
+ if (BLOSCLZ_UNLIKELY(op + 1 > op_limit)) \
+ goto out; \
+ *op++ = (uint8_t)((7U << 5U) + (distance >> 8U)); \
+ for (len -= 7; len >= 255; len -= 255) { \
+ if (BLOSCLZ_UNLIKELY(op + 1 > op_limit)) \
+ goto out; \
+ *op++ = 255; \
+ } \
+ if (BLOSCLZ_UNLIKELY(op + 2 > op_limit)) \
+ goto out; \
+ *op++ = (uint8_t)len; \
+ *op++ = (uint8_t)((distance & 255U)); \
+}
+
+#define DISTANCE_SHORT_FAR(op, op_limit, len, distance) { \
+ if (BLOSCLZ_UNLIKELY(op + 4 > op_limit)) \
+ goto out; \
+ *op++ = (uint8_t)((len << 5U) + 31); \
+ *op++ = 255; \
+ *op++ = (uint8_t)(distance >> 8U); \
+ *op++ = (uint8_t)(distance & 255U); \
+}
+
+#define DISTANCE_LONG_FAR(op, op_limit, len, distance) { \
+ if (BLOSCLZ_UNLIKELY(op + 1 > op_limit)) \
+ goto out; \
+ *op++ = (7U << 5U) + 31; \
+ for (len -= 7; len >= 255; len -= 255) { \
+ if (BLOSCLZ_UNLIKELY(op + 1 > op_limit)) \
+ goto out; \
+ *op++ = 255; \
+ } \
+ if (BLOSCLZ_UNLIKELY(op + 4 > op_limit)) \
+ goto out; \
+ *op++ = (uint8_t)len; \
+ *op++ = 255; \
+ *op++ = (uint8_t)(distance >> 8U); \
+ *op++ = (uint8_t)(distance & 255U); \
+}
+
+
+// Get the compressed size of a buffer. Useful for testing compression ratios for high clevels.
+static int get_csize(uint8_t* ibase, int maxlen, bool force_3b_shift) {
+ uint8_t* ip = ibase;
+ int32_t oc = 0;
+ uint8_t* ip_bound = ibase + maxlen - 1;
+ uint8_t* ip_limit = ibase + maxlen - 12;
+ uint32_t htab[1U << (uint8_t)HASH_LOG];
+ uint32_t hval;
+ uint32_t seq;
+ uint8_t copy;
+
+ // Initialize the hash table to distances of 0
+ for (unsigned i = 0; i < (1U << HASH_LOG); i++) {
+ htab[i] = 0;
+ }
+
+ /* we start with literal copy */
+ copy = 4;
+ oc += 5;
+
+ /* main loop */
+ while (BLOSCLZ_LIKELY(ip < ip_limit)) {
+ const uint8_t* ref;
+ unsigned distance;
+ uint8_t* anchor = ip; /* comparison starting-point */
+
+ /* find potential match */
+ seq = BLOSCLZ_READU32(ip);
+ HASH_FUNCTION(hval, seq, HASH_LOG)
+ ref = ibase + htab[hval];
+
+ /* calculate distance to the match */
+ distance = anchor - ref;
+
+ /* update hash table */
+ htab[hval] = (uint32_t) (anchor - ibase);
+
+ if (distance == 0 || (distance >= MAX_FARDISTANCE)) {
+ LITERAL2(ip, oc, anchor, copy)
+ continue;
+ }
+
+ /* is this a match? check the first 4 bytes */
+ if (BLOSCLZ_UNLIKELY(BLOSCLZ_READU32(ref) == BLOSCLZ_READU32(ip))) {
+ ref += 4;
+ }
+ else {
+ /* no luck, copy as a literal */
+ LITERAL2(ip, oc, anchor, copy)
+ continue;
+ }
+
+ /* last matched byte */
+ ip = anchor + 4;
+
+ /* distance is biased */
+ distance--;
+
+ /* get runs or matches; zero distance means a run */
+ ip = get_run_or_match(ip, ip_bound, ref, !distance);
+
+ ip -= force_3b_shift ? 3 : 4;
+ unsigned len = (int)(ip - anchor);
+ // If match is close, let's reduce the minimum length to encode it
+ unsigned minlen = (distance < MAX_DISTANCE) ? 3 : 4;
+ // Encoding short lengths is expensive during decompression
+ if (len < minlen) {
+ LITERAL2(ip, oc, anchor, copy)
+ continue;
+ }
+
+ /* if we have'nt copied anything, adjust the output counter */
+ if (!copy)
+ oc--;
+ /* reset literal counter */
+ copy = 0;
+
+ /* encode the match */
+ if (distance < MAX_DISTANCE) {
+ if (len >= 7) {
+ oc += ((len - 7) / 255) + 1;
+ }
+ oc += 2;
+ }
+ else {
+ /* far away, but not yet in the another galaxy... */
+ if (len >= 7) {
+ oc += ((len - 7) / 255) + 1;
+ }
+ oc += 4;
+ }
+
+ /* update the hash at match boundary */
+ seq = BLOSCLZ_READU32(ip);
+ HASH_FUNCTION(hval, seq, HASH_LOG)
+ htab[hval] = (uint32_t) (ip++ - ibase);
+ seq >>= 8U;
+ HASH_FUNCTION(hval, seq, HASH_LOG)
+ htab[hval] = (uint32_t) (ip++ - ibase);
+ /* assuming literal copy */
+ oc++;
+
+ }
+
+ /* if we have copied something, adjust the copy length */
+ if (!copy)
+ oc--;
+
+ return (int)oc;
+}
+
+
int blosclz_compress(const int clevel, const void* input, int length,
void* output, int maxout) {
uint8_t* ibase = (uint8_t*)input;
@@ -321,17 +519,16 @@ int blosclz_compress(const int clevel, const void* input, int length,
uint32_t seq;
uint8_t copy;
- // Minimum cratios before issuing and _early giveup_
- // Remind that blosclz is not meant for cratios <= 2 (too costly to decompress)
- double maxlength_[10] = {-1, .07, .1, .15, .25, .45, .5, .5, .5, .5};
- int32_t maxlength = (int32_t)(length * maxlength_[clevel]);
- if (maxlength > (int32_t)maxout) {
- maxlength = (int32_t)maxout;
- }
- op_limit = op + maxlength;
+ op_limit = op + maxout;
+
+ // Minimum lengths for encoding
+ unsigned minlen_[10] = {0, 12, 12, 11, 10, 9, 8, 7, 6, 5};
+
+ // Minimum compression ratios for initiate encoding
+ double cratio_[10] = {0, 2, 2, 2, 2, 1.8, 1.6, 1.4, 1.2, 1.1};
uint8_t hashlog_[10] = {0, HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG,
- HASH_LOG, HASH_LOG, HASH_LOG, HASH_LOG, HASH_LOG};
+ HASH_LOG, HASH_LOG, HASH_LOG, HASH_LOG, HASH_LOG};
uint8_t hashlog = hashlog_[clevel];
// Initialize the hash table to distances of 0
for (unsigned i = 0; i < (1U << hashlog); i++) {
@@ -343,6 +540,53 @@ int blosclz_compress(const int clevel, const void* input, int length,
return 0;
}
+ /* When we go back in a match (shift), we obtain quite different compression properties.
+ * It looks like 4 is more useful in combination with bitshuffle and small typesizes
+ * (compress better and faster in e.g. `b2bench blosclz bitshuffle single 6 6291456 1 19`).
+ * Fallback to 4 because it provides more consistent results on small itemsizes.
+ *
+ * In this block we also check cratios for the beginning of the buffers and
+ * eventually discard those that are small (take too long to decompress).
+ * This process is called _entropy probing_.
+ */
+ int ipshift = 4;
+ int maxlen; // maximum length for entropy probing
+ int csize_3b;
+ int csize_4b;
+ double cratio = 0;
+ switch (clevel) {
+ case 1:
+ case 2:
+ case 3:
+ maxlen = length / 8;
+ csize_4b = get_csize(ibase, maxlen, false);
+ cratio = (double)maxlen / csize_4b;
+ break;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ maxlen = length / 8;
+ csize_4b = get_csize(ibase, maxlen, false);
+ cratio = (double)maxlen / csize_4b;
+ break;
+ case 9:
+ // case 9 is special. we need to asses the optimal shift
+ maxlen = length / 8;
+ csize_3b = get_csize(ibase, maxlen, true);
+ csize_4b = get_csize(ibase, maxlen, false);
+ ipshift = (csize_3b < csize_4b) ? 3 : 4;
+ cratio = (csize_3b < csize_4b) ? ((double)maxlen / csize_3b) : ((double)maxlen / csize_4b);
+ break;
+ default:
+ break;
+ }
+ // discard probes with small compression ratios (too expensive)
+ if (cratio < cratio_ [clevel]) {
+ goto out;
+ }
+
/* we start with literal copy */
copy = 4;
*op++ = MAX_COPY - 1;
@@ -352,9 +596,9 @@ int blosclz_compress(const int clevel, const void* input, int length,
*op++ = *ip++;
/* main loop */
- while (BLOSCLZ_EXPECT_CONDITIONAL(ip < ip_limit)) {
+ while (BLOSCLZ_LIKELY(ip < ip_limit)) {
const uint8_t* ref;
- uint32_t distance;
+ unsigned distance;
uint8_t* anchor = ip; /* comparison starting-point */
/* find potential match */
@@ -363,7 +607,7 @@ int blosclz_compress(const int clevel, const void* input, int length,
ref = ibase + htab[hval];
/* calculate distance to the match */
- distance = (int32_t)(anchor - ref);
+ distance = anchor - ref;
/* update hash table */
htab[hval] = (uint32_t) (anchor - ibase);
@@ -374,10 +618,9 @@ int blosclz_compress(const int clevel, const void* input, int length,
}
/* is this a match? check the first 4 bytes */
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(BLOSCLZ_READU32(ref) == BLOSCLZ_READU32(ip))) {
+ if (BLOSCLZ_UNLIKELY(BLOSCLZ_READU32(ref) == BLOSCLZ_READU32(ip))) {
ref += 4;
- }
- else {
+ } else {
/* no luck, copy as a literal */
LITERAL(ip, op, op_limit, anchor, copy)
continue;
@@ -389,24 +632,21 @@ int blosclz_compress(const int clevel, const void* input, int length,
/* distance is biased */
distance--;
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(!distance)) {
- /* zero distance means a run */
-#if defined(__AVX2__)
- ip = get_run_32(ip, ip_bound, ref);
-#elif defined(__SSE2__)
- ip = get_run_16(ip, ip_bound, ref);
-#else
- ip = get_run(ip, ip_bound, ref);
-#endif
- }
- else {
-#if defined(__AVX2__)
- ip = get_match_32(ip, ip_bound, ref);
-#elif defined(__SSE2__)
- ip = get_match_16(ip, ip_bound, ref);
-#else
- ip = get_match(ip, ip_bound, ref);
-#endif
+ /* get runs or matches; zero distance means a run */
+ ip = get_run_or_match(ip, ip_bound, ref, !distance);
+
+ /* length is biased, '1' means a match of 3 bytes */
+ ip -= ipshift;
+
+ unsigned len = (int)(ip - anchor);
+ // If match is close, let's reduce the minimum length to encode it
+ unsigned minlen = (clevel == 9) ? ipshift : minlen_[clevel];
+
+ // Encoding short lengths is expensive during decompression
+ // Encode only for reasonable lengths (extensive experiments done)
+ if (len < minlen || (len <= 5 && distance >= MAX_DISTANCE)) {
+ LITERAL(ip, op, op_limit, anchor, copy)
+ continue;
}
/* if we have copied something, adjust the copy count */
@@ -416,50 +656,23 @@ int blosclz_compress(const int clevel, const void* input, int length,
else
/* back, to overwrite the copy count */
op--;
-
/* reset literal counter */
copy = 0;
- /* length is biased, '1' means a match of 3 bytes */
- /* When we get back by 4 we obtain quite different compression properties.
- * It looks like 4 is more useful in combination with bitshuffle and small typesizes
- * (compress better and faster in e.g. `b2bench blosclz bitshuffle single 6 6291456 1 19`).
- * Worth experimenting with this in the future. For the time being, use 3 for high clevels. */
- ip -= clevel > 8 ? 3 : 4;
- long len = ip - anchor;
-
/* encode the match */
if (distance < MAX_DISTANCE) {
if (len < 7) {
- *op++ = (uint8_t)((len << 5U) + (distance >> 8U));
- *op++ = (uint8_t)((distance & 255U));
- }
- else {
- *op++ = (uint8_t)((7U << 5U) + (distance >> 8U));
- for (len -= 7; len >= 255; len -= 255)
- *op++ = 255;
- *op++ = (uint8_t)len;
- *op++ = (uint8_t)((distance & 255U));
+ DISTANCE_SHORT(op, op_limit, len, distance)
+ } else {
+ DISTANCE_LONG(op, op_limit, len, distance)
}
- }
- else {
+ } else {
/* far away, but not yet in the another galaxy... */
+ distance -= MAX_DISTANCE;
if (len < 7) {
- distance -= MAX_DISTANCE;
- *op++ = (uint8_t)((len << 5U) + 31);
- *op++ = 255;
- *op++ = (uint8_t)(distance >> 8U);
- *op++ = (uint8_t)(distance & 255U);
- }
- else {
- distance -= MAX_DISTANCE;
- *op++ = (7U << 5U) + 31;
- for (len -= 7; len >= 255; len -= 255)
- *op++ = 255;
- *op++ = (uint8_t)len;
- *op++ = 255;
- *op++ = (uint8_t)(distance >> 8U);
- *op++ = (uint8_t)(distance & 255U);
+ DISTANCE_SHORT_FAR(op, op_limit, len, distance)
+ } else {
+ DISTANCE_LONG_FAR(op, op_limit, len, distance)
}
}
@@ -471,16 +684,18 @@ int blosclz_compress(const int clevel, const void* input, int length,
HASH_FUNCTION(hval, seq, hashlog)
htab[hval] = (uint32_t) (ip++ - ibase);
/* assuming literal copy */
- *op++ = MAX_COPY - 1;
+ if (BLOSCLZ_UNLIKELY(op + 1 > op_limit))
+ goto out;
+ *op++ = MAX_COPY - 1;
}
/* left-over as literal copy */
- while (BLOSCLZ_UNEXPECT_CONDITIONAL(ip <= ip_bound)) {
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(op + 2 > op_limit)) goto out;
+ while (BLOSCLZ_UNLIKELY(ip <= ip_bound)) {
+ if (BLOSCLZ_UNLIKELY(op + 2 > op_limit)) goto out;
*op++ = *ip++;
copy++;
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(copy == MAX_COPY)) {
+ if (BLOSCLZ_UNLIKELY(copy == MAX_COPY)) {
copy = 0;
*op++ = MAX_COPY - 1;
}
@@ -499,7 +714,6 @@ int blosclz_compress(const int clevel, const void* input, int length,
out:
return 0;
-
}
// See https://habr.com/en/company/yandex/blog/457612/
@@ -572,23 +786,22 @@ int blosclz_decompress(const void* input, int length, void* output, int maxout)
uint8_t* op = (uint8_t*)output;
uint32_t ctrl;
uint8_t* op_limit = op + maxout;
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(length == 0)) {
+ if (BLOSCLZ_UNLIKELY(length == 0)) {
return 0;
}
ctrl = (*ip++) & 31U;
while (1) {
- uint8_t* ref = op;
- int32_t len = ctrl >> 5U;
- int32_t ofs = (ctrl & 31U) << 8U;
-
if (ctrl >= 32) {
+ // match
+ int32_t len = (ctrl >> 5U) - 1 ;
+ int32_t ofs = (ctrl & 31U) << 8U;
uint8_t code;
- len--;
- ref -= ofs;
+ const uint8_t* ref = op - ofs;
+
if (len == 7 - 1) {
do {
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(ip + 1 >= ip_limit)) {
+ if (BLOSCLZ_UNLIKELY(ip + 1 >= ip_limit)) {
return 0;
}
code = *ip++;
@@ -596,17 +809,18 @@ int blosclz_decompress(const void* input, int length, void* output, int maxout)
} while (code == 255);
}
else {
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(ip + 1 >= ip_limit)) {
+ if (BLOSCLZ_UNLIKELY(ip + 1 >= ip_limit)) {
return 0;
}
}
code = *ip++;
+ len += 3;
ref -= code;
/* match from 16-bit distance */
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(code == 255)) {
- if (BLOSCLZ_EXPECT_CONDITIONAL(ofs == (31U << 8U))) {
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(ip + 1 >= ip_limit)) {
+ if (BLOSCLZ_UNLIKELY(code == 255)) {
+ if (ofs == (31U << 8U)) {
+ if (ip + 1 >= ip_limit) {
return 0;
}
ofs = (*ip++) << 8U;
@@ -615,29 +829,30 @@ int blosclz_decompress(const void* input, int length, void* output, int maxout)
}
}
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit)) {
+ if (BLOSCLZ_UNLIKELY(op + len > op_limit)) {
return 0;
}
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(ref - 1 < (uint8_t*)output)) {
+ if (BLOSCLZ_UNLIKELY(ref - 1 < (uint8_t*)output)) {
return 0;
}
- if (BLOSCLZ_EXPECT_CONDITIONAL(ip < ip_limit))
- ctrl = *ip++;
- else
- break;
+ if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) break;
+ ctrl = *ip++;
- if (ref == op) {
+ ref--;
+ if (ref == op - 1) {
/* optimized copy for a run */
- uint8_t b = ref[-1];
- memset(op, b, len + 3);
- op += len + 3;
+ memset(op, *ref, len);
+ op += len;
+ }
+ else if ((op - ref >= 8) && (op_limit - op >= len + 8)) {
+ // copy with an overlap not larger than 8
+ wild_copy(op, ref, op + len);
+ op += len;
}
else {
- /* copy from reference */
- ref--;
- len += 3;
+ // general copy with any overlap
#ifdef __AVX2__
if (op - ref <= 16) {
// This is not faster on a combination of compilers (clang, gcc, icc) or machines, but
@@ -646,27 +861,19 @@ int blosclz_decompress(const void* input, int length, void* output, int maxout)
}
else {
#endif
- uint8_t* endcpy = op + len;
- if ((op - ref < 8) || (op_limit - endcpy < 8)) {
- // We absolutely need a copy_match here
- op = copy_match(op, ref, (unsigned) len);
- }
- else {
- wild_copy(op, ref, endcpy);
- op = endcpy;
- }
-
+ op = copy_match(op, ref, (unsigned) len);
#ifdef __AVX2__
}
#endif
}
}
else {
+ // literal
ctrl++;
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(op + ctrl > op_limit)) {
+ if (BLOSCLZ_UNLIKELY(op + ctrl > op_limit)) {
return 0;
}
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(ip + ctrl > ip_limit)) {
+ if (BLOSCLZ_UNLIKELY(ip + ctrl > ip_limit)) {
return 0;
}
@@ -677,7 +884,7 @@ int blosclz_decompress(const void* input, int length, void* output, int maxout)
// And starting on CLANG/LLVM 10 and GCC 9, memcpy is generally faster.
// op = fastcopy(op, ip, (unsigned) ctrl); ip += ctrl;
- if (BLOSCLZ_UNEXPECT_CONDITIONAL(ip >= ip_limit)) break;
+ if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) break;
ctrl = *ip++;
}
}
|
3rdn4/c-blosc:41f3a2e-heap_buffer_overflow
|
/workspace/skyset/
|
c-blosc
|
41f3a2e-heap_buffer_overflow
|
/workspace/skyset/c-blosc/41f3a2e-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/c-blosc/41f3a2e-heap_buffer_overflow/immutable/
|
From 8f702156e8c9ecc8bbcbabfc0d8ee38bc294dddd Mon Sep 17 00:00:00 2001
From: Francesc Alted <[email protected]>
Date: Tue, 28 Sep 2021 18:19:59 +0200
Subject: [PATCH] BloscLZ version bumped to 2.5.1
---
blosc/blosc.h | 2 +-
blosc/blosclz.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/blosc/blosc.h b/blosc/blosc.h
index c1ff3944..77a2411f 100644
--- a/blosc/blosc.h
+++ b/blosc/blosc.h
@@ -25,7 +25,7 @@ extern "C" {
#define BLOSC_VERSION_REVISION "$Rev$" /* revision version */
#define BLOSC_VERSION_DATE "$Date:: 2020-12-22 #$" /* date version */
-#define BLOSCLZ_VERSION_STRING "2.5.0" /* the internal compressor version */
+#define BLOSCLZ_VERSION_STRING "2.5.1" /* the internal compressor version */
/* The *_FORMAT symbols should be just 1-byte long */
#define BLOSC_VERSION_FORMAT 2 /* Blosc format version, starting at 1 */
diff --git a/blosc/blosclz.c b/blosc/blosclz.c
index 4e1f648f..a0552c2c 100644
--- a/blosc/blosclz.c
+++ b/blosc/blosclz.c
@@ -462,6 +462,7 @@ int blosclz_compress(const int clevel, const void* input, int length,
const uint8_t* ip_bound = ibase + length - 1;
const uint8_t* ip_limit = ibase + length - 12;
uint8_t* op = (uint8_t*)output;
+ const uint8_t* op_limit = op + maxout;
/* input and output buffer cannot be less than 16 and 66 bytes or we can get into trouble */
if (length < 16 || maxout < 66) {
@@ -481,7 +482,6 @@ int blosclz_compress(const int clevel, const void* input, int length,
*op++ = *ip++;
/* main loop */
- const uint8_t* op_limit = op + maxout;
while (BLOSCLZ_LIKELY(ip < ip_limit)) {
const uint8_t* ref;
unsigned distance;
|
3rdn4/c-blosc2:38b23d5-negative_size_param
|
/workspace/skyset/
|
c-blosc2
|
38b23d5-negative_size_param
|
/workspace/skyset/c-blosc2/38b23d5-negative_size_param/report.txt
|
A negative size param found in /workspace/skyset/c-blosc2/38b23d5-negative_size_param/immutable/
|
From ac7b9359e84d796bfb1ff1fd3f7c9eaf9a506799 Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Mon, 10 May 2021 07:41:00 -0700
Subject: [PATCH] Added typesize check when reading frame header info.
https://oss-fuzz.com/testcase-detail/6103287616110592
---
blosc/frame.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/blosc/frame.c b/blosc/frame.c
index 83e4a7b6b..29a106ac8 100644
--- a/blosc/frame.c
+++ b/blosc/frame.c
@@ -409,7 +409,15 @@ int get_header_info(blosc2_frame_s *frame, int32_t *header_len, int64_t *frame_l
// Fetch some internal lengths
from_big(header_len, framep + FRAME_HEADER_LEN, sizeof(*header_len));
+ if (*header_len < FRAME_HEADER_MINLEN) {
+ BLOSC_TRACE_ERROR("Header length is zero or smaller than min allowed.");
+ return BLOSC2_ERROR_INVALID_HEADER;
+ }
from_big(frame_len, framep + FRAME_LEN, sizeof(*frame_len));
+ if (*header_len > *frame_len) {
+ BLOSC_TRACE_ERROR("Header length exceeds length of the frame.");
+ return BLOSC2_ERROR_INVALID_HEADER;
+ }
from_big(nbytes, framep + FRAME_NBYTES, sizeof(*nbytes));
from_big(cbytes, framep + FRAME_CBYTES, sizeof(*cbytes));
from_big(blocksize, framep + FRAME_BLOCKSIZE, sizeof(*blocksize));
@@ -418,11 +426,10 @@ int get_header_info(blosc2_frame_s *frame, int32_t *header_len, int64_t *frame_l
}
if (typesize != NULL) {
from_big(typesize, framep + FRAME_TYPESIZE, sizeof(*typesize));
- }
-
- if (*header_len < FRAME_HEADER_MINLEN || *header_len > *frame_len) {
- BLOSC_TRACE_ERROR("Header length is invalid or exceeds length of the frame.");
- return BLOSC2_ERROR_INVALID_HEADER;
+ if (*typesize <= 0 || *typesize > BLOSC_MAX_TYPESIZE) {
+ BLOSC_TRACE_ERROR("`typesize` is zero or greater than max allowed.");
+ return BLOSC2_ERROR_INVALID_HEADER;
+ }
}
// Codecs
|
3rdn4/c-blosc2:4f6d42a-invalid_free
|
/workspace/skyset/
|
c-blosc2
|
4f6d42a-invalid_free
|
/workspace/skyset/c-blosc2/4f6d42a-invalid_free/report.txt
|
A invalid free found in /workspace/skyset/c-blosc2/4f6d42a-invalid_free/immutable/
|
From 1a79d783cc791faf12fa9f6f6f92c26fb8be4967 Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Fri, 12 Mar 2021 17:48:39 -0800
Subject: [PATCH] Fixed ASAN null-deference read trying to free chunk that has
already been free. https://oss-fuzz.com/testcase-detail/5107303620673536
---
blosc/frame.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blosc/frame.c b/blosc/frame.c
index 43af22eb5..eb91fc441 100644
--- a/blosc/frame.c
+++ b/blosc/frame.c
@@ -2032,7 +2032,7 @@ int frame_get_lazychunk(blosc2_frame_s *frame, int nchunk, uint8_t **chunk, bool
fclose(fp);
}
if (rc < 0) {
- if (needs_free) {
+ if (*needs_free) {
free(*chunk);
*chunk = NULL;
}
|
3rdn4/c-blosc2:6fc4790-heap_buffer_overflow_b
|
/workspace/skyset/
|
c-blosc2
|
6fc4790-heap_buffer_overflow_b
|
/workspace/skyset/c-blosc2/6fc4790-heap_buffer_overflow_b/report.txt
|
A heap buffer overflow b found in /workspace/skyset/c-blosc2/6fc4790-heap_buffer_overflow_b/immutable/
|
From 4f6d42ab4b25e781dad94c5324dab8a4dbb702ad Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Mon, 1 Mar 2021 20:06:43 -0800
Subject: [PATCH] Fixed ASAN heap-buffer-overflow when reading chunk offset in
frame. https://oss-fuzz.com/testcase-detail/4753813014708224
---
blosc/frame.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blosc/frame.c b/blosc/frame.c
index 45fa58fed..43af22eb5 100644
--- a/blosc/frame.c
+++ b/blosc/frame.c
@@ -994,7 +994,7 @@ uint8_t* get_coffsets(blosc2_frame_s *frame, int32_t header_len, int64_t cbytes,
return NULL;
}
*off_cbytes = (int32_t)chunk_cbytes;
- if (*off_cbytes < 0 || *off_cbytes > frame->len) {
+ if (*off_cbytes < 0 || off_pos + *off_cbytes > frame->len) {
BLOSC_TRACE_ERROR("Cannot read the cbytes outside of frame boundary.");
return NULL;
}
|
3rdn4/c-blosc2:81c2fcd-heap_buffer_overflow_b
|
/workspace/skyset/
|
c-blosc2
|
81c2fcd-heap_buffer_overflow_b
|
/workspace/skyset/c-blosc2/81c2fcd-heap_buffer_overflow_b/report.txt
|
A heap buffer overflow b found in /workspace/skyset/c-blosc2/81c2fcd-heap_buffer_overflow_b/immutable/
|
From ce9aa2247006ed182dabb922bd3536b13375c4cf Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Mon, 12 Apr 2021 19:12:00 -0700
Subject: [PATCH] Fixed ASAN heap-buffer-overflow when reading frame
vlmetalayers. When reading content we should not be using trailer_pos to
check bounds as it is only used to enumerate offsets.
https://oss-fuzz.com/testcase-detail/5533861342740480
---
blosc/frame.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/blosc/frame.c b/blosc/frame.c
index 04e41ba2a..6b27d3a36 100644
--- a/blosc/frame.c
+++ b/blosc/frame.c
@@ -1365,16 +1365,15 @@ static int get_vlmeta_from_trailer(blosc2_frame_s* frame, blosc2_schunk* schunk,
}
// Go to offset and see if we have the correct marker
uint8_t* content_marker = trailer + offset;
+ if (trailer_len < offset + 1 + 4) {
+ return BLOSC2_ERROR_READ_BUFFER;
+ }
if (*content_marker != 0xc6) {
return BLOSC2_ERROR_DATA;
}
// Read the size of the content
int32_t content_len;
- trailer_pos += sizeof(content_len);
- if (trailer_len < trailer_pos) {
- return BLOSC2_ERROR_READ_BUFFER;
- }
from_big(&content_len, content_marker + 1, sizeof(content_len));
if (content_len < 0) {
return BLOSC2_ERROR_DATA;
@@ -1382,8 +1381,7 @@ static int get_vlmeta_from_trailer(blosc2_frame_s* frame, blosc2_schunk* schunk,
metalayer->content_len = content_len;
// Finally, read the content
- trailer_pos += content_len;
- if (trailer_len < trailer_pos) {
+ if (trailer_len < offset + 1 + 4 + content_len) {
return BLOSC2_ERROR_READ_BUFFER;
}
char* content = malloc((size_t)content_len);
|
3rdn4/c-blosc2:81c2fcd-heap_buffer_overflow_c
|
/workspace/skyset/
|
c-blosc2
|
81c2fcd-heap_buffer_overflow_c
|
/workspace/skyset/c-blosc2/81c2fcd-heap_buffer_overflow_c/report.txt
|
A heap buffer overflow c found in /workspace/skyset/c-blosc2/81c2fcd-heap_buffer_overflow_c/immutable/
|
From 8a058b7a6be4d7e47a9af5831c454fca8c725dd4 Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Sat, 8 May 2021 11:38:00 -0700
Subject: [PATCH] Fixed ASAN heap-buffer-overflow when reading frame
metalayers. Similar to #279. Variable header_pos is used for checking
boundaries when reading name/offsets. Don't need to increase header_pos when
seeking to another offset in the header to read metadata.
https://oss-fuzz.com/testcase-detail/5361858753200128
---
blosc/frame.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/blosc/frame.c b/blosc/frame.c
index 4bfae62f9..9edf6588f 100644
--- a/blosc/frame.c
+++ b/blosc/frame.c
@@ -1285,16 +1285,15 @@ static int get_meta_from_header(blosc2_frame_s* frame, blosc2_schunk* schunk, ui
}
// Go to offset and see if we have the correct marker
uint8_t* content_marker = header + offset;
+ if (header_len < offset + 1 + 4) {
+ return BLOSC2_ERROR_READ_BUFFER;
+ }
if (*content_marker != 0xc6) {
return BLOSC2_ERROR_DATA;
}
// Read the size of the content
int32_t content_len;
- header_pos += sizeof(content_len);
- if (header_len < header_pos) {
- return BLOSC2_ERROR_READ_BUFFER;
- }
from_big(&content_len, content_marker + 1, sizeof(content_len));
if (content_len < 0) {
return BLOSC2_ERROR_DATA;
@@ -1302,8 +1301,7 @@ static int get_meta_from_header(blosc2_frame_s* frame, blosc2_schunk* schunk, ui
metalayer->content_len = content_len;
// Finally, read the content
- header_pos += content_len;
- if (header_len < header_pos) {
+ if (header_len < offset + 1 + 4 + content_len) {
return BLOSC2_ERROR_READ_BUFFER;
}
char* content = malloc((size_t)content_len);
|
3rdn4/c-blosc2:aebf2b9-heap_buffer_overflow
|
/workspace/skyset/
|
c-blosc2
|
aebf2b9-heap_buffer_overflow
|
/workspace/skyset/c-blosc2/aebf2b9-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/c-blosc2/aebf2b9-heap_buffer_overflow/immutable/
|
From f00f545b17cbb9958e9da054d137dbf0edd60331 Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Sat, 23 Jan 2021 18:41:11 -0800
Subject: [PATCH] Fixed ASAN error due to invalid header length.
https://oss-fuzz.com/testcase-detail/6021380745330688
---
blosc/frame.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blosc/frame.c b/blosc/frame.c
index a87d691eb..40b4a9b6c 100644
--- a/blosc/frame.c
+++ b/blosc/frame.c
@@ -423,8 +423,8 @@ int get_header_info(blosc2_frame *frame, int32_t *header_len, int64_t *frame_len
swap_store(typesize, framep + FRAME_TYPESIZE, sizeof(*typesize));
}
- if (*header_len > *frame_len) {
- BLOSC_TRACE_ERROR("Header length exceeds length of the frame.");
+ if (*header_len <= 0 || *header_len > *frame_len) {
+ BLOSC_TRACE_ERROR("Header length is invalid or exceeds length of the frame.");
return -1;
}
|
3rdn4/c-blosc2:cb15f1b-unknown_read
|
/workspace/skyset/
|
c-blosc2
|
cb15f1b-unknown_read
|
/workspace/skyset/c-blosc2/cb15f1b-unknown_read/report.txt
|
A unknown read found in /workspace/skyset/c-blosc2/cb15f1b-unknown_read/immutable/
|
From 61aae4f319ac801ead90d789cbd7f7e3f2efd133 Mon Sep 17 00:00:00 2001
From: Nathan Moinvaziri <[email protected]>
Date: Fri, 29 Jan 2021 17:47:36 -0800
Subject: [PATCH] Fixed ASAN unknown-read when reading stream if previous
stream cbytes < 0. https://oss-fuzz.com/testcase-detail/4727058852872192
---
blosc/blosc2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blosc/blosc2.c b/blosc/blosc2.c
index 695a7fc14..0b9f512c2 100644
--- a/blosc/blosc2.c
+++ b/blosc/blosc2.c
@@ -1160,9 +1160,9 @@ static int blosc_d(
}
uint8_t value = -cbytes;
memset(_dest, value, (unsigned int) neblock);
- nbytes = neblock;
- cbytes = 0; // everything is encoded in the cbytes token
}
+ nbytes = neblock;
+ cbytes = 0; // everything is encoded in the cbytes token
}
else if (cbytes == neblock) {
memcpy(_dest, src, (unsigned int)neblock);
|
3rdn4/extractfix-binutils:515f23e-divide_by_zero
|
/workspace/skyset/
|
extractfix-binutils
|
515f23e-divide_by_zero
|
/workspace/skyset/extractfix-binutils/515f23e-divide_by_zero/report.txt
|
A divide by zero found in /workspace/skyset/extractfix-binutils/515f23e-divide_by_zero/immutable/
|
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f63a8bb1694..e232764448d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-24 Alan Modra <[email protected]>
+
+ PR 22186
+ * dwarf2.c (decode_line_info): Fail on lh.line_range of zero
+ rather than dividing by zero.
+
2017-09-24 Alan Modra <[email protected]>
PR 22169
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 89a3f9b1830..8b2281ee86c 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2437,6 +2437,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
case DW_LNS_set_basic_block:
break;
case DW_LNS_const_add_pc:
+ if (lh.line_range == 0)
+ goto line_fail;
if (lh.maximum_ops_per_insn == 1)
address += (lh.minimum_instruction_length
* ((255 - lh.opcode_base) / lh.line_range));
|
3rdn4/extractfix-binutils:c48935d-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-binutils
|
c48935d-heap_buffer_overflow
|
/workspace/skyset/extractfix-binutils/c48935d-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-binutils/c48935d-heap_buffer_overflow/immutable/
|
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 1b63c7d0184..5219cb129e9 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-17 Nick Clifton <[email protected]>
+
+ PR 23064
+ * dwarf.c (process_cu_tu_index): Test for a potential buffer
+ overrun before copying signature pointer.
+
2018-04-17 Alan Modra <[email protected]>
* readelf.c: Revert 2018-04-16 and 2018-04-11 changes.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 10b4e284ce3..f94f5b2fe69 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -9287,7 +9287,18 @@ process_cu_tu_index (struct dwarf_section *section, int do_display)
}
if (!do_display)
- memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t));
+ {
+ size_t num_copy = sizeof (uint64_t);
+
+ /* PR 23064: Beware of buffer overflow. */
+ if (ph + num_copy < limit)
+ memcpy (&this_set[row - 1].signature, ph, num_copy);
+ else
+ {
+ warn (_("Signature (%p) extends beyond end of space in section\n"), ph);
+ return 0;
+ }
+ }
prow = poffsets + (row - 1) * ncols * 4;
/* PR 17531: file: b8ce60a8. */
|
3rdn4/extractfix-coreutils:658529a-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-coreutils
|
658529a-heap_buffer_overflow
|
/workspace/skyset/extractfix-coreutils/658529a-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-coreutils/658529a-heap_buffer_overflow/immutable/
|
diff --git a/src/make-prime-list.c b/src/make-prime-list.c
index 68c972a84..69b91e895 100644
--- a/src/make-prime-list.c
+++ b/src/make-prime-list.c
@@ -211,7 +211,7 @@ main (int argc, char **argv)
for (j = (p*p - 3)/2; j < size; j+= p)
sieve[j] = 0;
- while (i < size && sieve[++i] == 0)
+ while (++i < size && sieve[i] == 0)
;
}
|
3rdn4/extractfix-jasper:3c55b39-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-jasper
|
3c55b39-heap_buffer_overflow
|
/workspace/skyset/extractfix-jasper/3c55b39-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-jasper/3c55b39-heap_buffer_overflow/immutable/
|
diff --git a/src/libjasper/jpc/jpc_cs.c b/src/libjasper/jpc/jpc_cs.c
index 6da4872..55d34d6 100644
--- a/src/libjasper/jpc/jpc_cs.c
+++ b/src/libjasper/jpc/jpc_cs.c
@@ -512,6 +512,16 @@ static int jpc_siz_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate,
jas_free(siz->comps);
return -1;
}
+ if (siz->comps[i].hsamp == 0 || siz->comps[i].hsamp > 255) {
+ jas_eprintf("invalid XRsiz value %d\n", siz->comps[i].hsamp);
+ jas_free(siz->comps);
+ return -1;
+ }
+ if (siz->comps[i].vsamp == 0 || siz->comps[i].vsamp > 255) {
+ jas_eprintf("invalid YRsiz value %d\n", siz->comps[i].vsamp);
+ jas_free(siz->comps);
+ return -1;
+ }
siz->comps[i].sgnd = (tmp >> 7) & 1;
siz->comps[i].prec = (tmp & 0x7f) + 1;
}
|
3rdn4/extractfix-jasper:b9be3d9-integer_overflow
|
/workspace/skyset/
|
extractfix-jasper
|
b9be3d9-integer_overflow
|
/workspace/skyset/extractfix-jasper/b9be3d9-integer_overflow/report.txt
|
A integer overflow found in /workspace/skyset/extractfix-jasper/b9be3d9-integer_overflow/immutable/
|
diff --git a/src/libjasper/jpc/jpc_dec.c b/src/libjasper/jpc/jpc_dec.c
index d2f258e..4f24660 100644
--- a/src/libjasper/jpc/jpc_dec.c
+++ b/src/libjasper/jpc/jpc_dec.c
@@ -1195,6 +1195,7 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
int htileno;
int vtileno;
jpc_dec_cmpt_t *cmpt;
+ size_t size;
dec->xstart = siz->xoff;
dec->ystart = siz->yoff;
@@ -1231,7 +1232,10 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);
dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);
- dec->numtiles = dec->numhtiles * dec->numvtiles;
+ if (!jas_safe_size_mul(dec->numhtiles, dec->numvtiles, &size)) {
+ return -1;
+ }
+ dec->numtiles = size;
JAS_DBGLOG(10, ("numtiles = %d; numhtiles = %d; numvtiles = %d;\n",
dec->numtiles, dec->numhtiles, dec->numvtiles));
if (!(dec->tiles = jas_alloc2(dec->numtiles, sizeof(jpc_dec_tile_t)))) {
|
3rdn4/extractfix-libjpeg-turbo:3212005-null_ptr_dereference
|
/workspace/skyset/
|
extractfix-libjpeg-turbo
|
3212005-null_ptr_dereference
|
/workspace/skyset/extractfix-libjpeg-turbo/3212005-null_ptr_dereference/report.txt
|
A null ptr dereference found in /workspace/skyset/extractfix-libjpeg-turbo/3212005-null_ptr_dereference/immutable/
|
diff --git a/jquant1.c b/jquant1.c
index e7814815..34965ed0 100644
--- a/jquant1.c
+++ b/jquant1.c
@@ -531,6 +531,9 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JDIMENSION col;
JDIMENSION width = cinfo->output_width;
+ if (output_buf == NULL) /* just want to update dither tables */
+ return;
+
for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */
jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
|
3rdn4/extractfix-libjpeg-turbo:4f24016-stack_buffer_overflow
|
/workspace/skyset/
|
extractfix-libjpeg-turbo
|
4f24016-stack_buffer_overflow
|
/workspace/skyset/extractfix-libjpeg-turbo/4f24016-stack_buffer_overflow/report.txt
|
A stack buffer overflow found in /workspace/skyset/extractfix-libjpeg-turbo/4f24016-stack_buffer_overflow/immutable/
|
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 8a8a29b5..3775d543 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -15,6 +15,10 @@ correct behavior of the colorspace extensions when merged upsampling is used.
upper 64 bits of xmm6 and xmm7 on Win64 platforms, which violated the Win64
calling conventions.
+[4] Fixed a regression caused by 1.2.0[6] whereby decompressing corrupt JPEG
+images (specifically, images in which the component count was erroneously set
+to a large value) would cause libjpeg-turbo to segfault.
+
1.2.0
=====
diff --git a/jdmarker.c b/jdmarker.c
index d8dcba98..6fc0f7dc 100644
--- a/jdmarker.c
+++ b/jdmarker.c
@@ -323,14 +323,15 @@ get_sos (j_decompress_ptr cinfo)
/* Collect the component-spec parameters */
- for (i = 0; i < cinfo->num_components; i++)
+ for (i = 0; i < MAX_COMPS_IN_SCAN; i++)
cinfo->cur_comp_info[i] = NULL;
for (i = 0; i < n; i++) {
INPUT_BYTE(cinfo, cc, return FALSE);
INPUT_BYTE(cinfo, c, return FALSE);
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ for (ci = 0, compptr = cinfo->comp_info;
+ ci < cinfo->num_components && ci < MAX_COMPS_IN_SCAN;
ci++, compptr++) {
if (cc == compptr->component_id && !cinfo->cur_comp_info[ci])
goto id_found;
|
3rdn4/extractfix-libjpeg-turbo:ae8cdf5-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libjpeg-turbo
|
ae8cdf5-heap_buffer_overflow
|
/workspace/skyset/extractfix-libjpeg-turbo/ae8cdf5-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libjpeg-turbo/ae8cdf5-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog.md b/ChangeLog.md
index 0e95df4f..9300f3a8 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -47,6 +47,11 @@ subsampling (for instance, 4:2:0 or 4:4:0.)
a 4:2:2 or 4:2:0 JPEG image using the merged (non-fancy) upsampling algorithms
(that is, when setting `cinfo.do_fancy_upsampling` to `FALSE`.)
+8. Fixed out-of-bounds read in cjpeg that occurred when attempting to compress
+a specially-crafted malformed color-index (8-bit-per-sample) BMP file in which
+some of the samples (color indices) exceeded the bounds of the BMP file's color
+table.
+
1.5.3
=====
diff --git a/cderror.h b/cderror.h
index 63de498f..e57a8c81 100644
--- a/cderror.h
+++ b/cderror.h
@@ -2,7 +2,7 @@
* cderror.h
*
* Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 2009 by Guido Vollbeding.
+ * Modified 2009-2017 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -49,6 +49,7 @@ JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
+JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image")
@@ -75,8 +76,8 @@ JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
#ifdef PPM_SUPPORTED
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
-JMESSAGE(JERR_PPM_TOOLARGE, "Integer value too large in PPM file")
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
+JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
JMESSAGE(JTRC_PGM, "%ux%u PGM image")
JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
JMESSAGE(JTRC_PPM, "%ux%u PPM image")
diff --git a/rdbmp.c b/rdbmp.c
index 6b73f7c0..5b45c44b 100644
--- a/rdbmp.c
+++ b/rdbmp.c
@@ -3,7 +3,7 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2009-2010 by Guido Vollbeding.
+ * Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Modified 2011 by Siarhei Siamashka.
* Copyright (C) 2015, 2018, D. R. Commander.
@@ -66,6 +66,7 @@ typedef struct _bmp_source_struct {
JDIMENSION row_width; /* Physical width of scanlines in file */
int bits_per_pixel; /* remembers 8- or 24-bit format */
+ int cmap_length; /* colormap length */
} bmp_source_struct;
@@ -126,6 +127,7 @@ get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
bmp_source_ptr source = (bmp_source_ptr) sinfo;
register JSAMPARRAY colormap = source->colormap;
+ int cmaplen = source->cmap_length;
JSAMPARRAY image_ptr;
register int t;
register JSAMPROW inptr, outptr;
@@ -142,6 +144,8 @@ get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
outptr = source->pub.buffer[0];
for (col = cinfo->image_width; col > 0; col--) {
t = GETJSAMPLE(*inptr++);
+ if (t >= cmaplen)
+ ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
*outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */
*outptr++ = colormap[1][t];
*outptr++ = colormap[2][t];
@@ -401,6 +405,7 @@ start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
source->colormap = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) biClrUsed, (JDIMENSION) 3);
+ source->cmap_length = (int) biClrUsed;
/* and read it from the file */
read_colormap(source, (int) biClrUsed, mapentrysize);
/* account for size of colormap */
diff --git a/rdppm.c b/rdppm.c
index 33ff7495..c0c09621 100644
--- a/rdppm.c
+++ b/rdppm.c
@@ -69,7 +69,7 @@ typedef struct {
JSAMPROW pixrow; /* compressor input buffer */
size_t buffer_width; /* width of I/O buffer */
JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
- int maxval;
+ unsigned int maxval;
} ppm_source_struct;
typedef ppm_source_struct *ppm_source_ptr;
@@ -119,7 +119,7 @@ read_pbm_integer (j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
}
if (val > maxval)
- ERREXIT(cinfo, JERR_PPM_TOOLARGE);
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
return val;
}
@@ -255,7 +255,7 @@ get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_TOOLARGE);
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
*ptr++ = rescale[temp];
}
return 1;
@@ -282,17 +282,17 @@ get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_TOOLARGE);
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
*ptr++ = rescale[temp];
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_TOOLARGE);
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
*ptr++ = rescale[temp];
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
- ERREXIT(cinfo, JERR_PPM_TOOLARGE);
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
*ptr++ = rescale[temp];
}
return 1;
|
3rdn4/extractfix-libtiff:0ba5d88-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
0ba5d88-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/0ba5d88-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/0ba5d88-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index e98d54d5..4e0302fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-07-11 Even Rouault <even.rouault at spatialys.com>
+
+ * tools/tiffcrop.c: Avoid access outside of stack allocated array
+ on a tiled separate TIFF with more than 8 samples per pixel.
+ Reported by Kaixiang Zhang of the Cloud Security Team, Qihoo 360
+ (CVE-2016-5321, bugzilla #2558)
+
2016-07-10 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_read.c: Fix out-of-bounds read on
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index d959ae30..6fc8fc1d 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -989,7 +989,7 @@ static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf,
nrow = (row + tl > imagelength) ? imagelength - row : tl;
for (col = 0; col < imagewidth; col += tw)
{
- for (s = 0; s < spp; s++)
+ for (s = 0; s < spp && s < MAX_SAMPLES; s++)
{ /* Read each plane of a tile set into srcbuffs[s] */
tbytes = TIFFReadTile(in, srcbuffs[s], col, row, 0, s);
if (tbytes < 0 && !ignore)
|
3rdn4/extractfix-libtiff:2c00d31-divide_by_zero
|
/workspace/skyset/
|
extractfix-libtiff
|
2c00d31-divide_by_zero
|
/workspace/skyset/extractfix-libtiff/2c00d31-divide_by_zero/report.txt
|
A divide by zero found in /workspace/skyset/extractfix-libtiff/2c00d31-divide_by_zero/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index c82bc76e..a7208f5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-11 Even Rouault <even.rouault at spatialys.com>
+
+ * libtiff/tif_jpeg.c: avoid integer division by zero in
+ JPEGSetupEncode() when horizontal or vertical sampling is set to 0.
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2653
+
2017-01-03 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_jpeg.c: increase libjpeg max memory usable to
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index 38595f98..6c17c388 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -1626,6 +1626,13 @@ JPEGSetupEncode(TIFF* tif)
case PHOTOMETRIC_YCBCR:
sp->h_sampling = td->td_ycbcrsubsampling[0];
sp->v_sampling = td->td_ycbcrsubsampling[1];
+ if( sp->h_sampling == 0 || sp->v_sampling == 0 )
+ {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Invalig horizontal/vertical sampling value");
+ return (0);
+ }
+
/*
* A ReferenceBlackWhite field *must* be present since the
* default value is inappropriate for YCbCr. Fill in the
|
3rdn4/extractfix-libtiff:3144e57-invalid_shift
|
/workspace/skyset/
|
extractfix-libtiff
|
3144e57-invalid_shift
|
/workspace/skyset/extractfix-libtiff/3144e57-invalid_shift/report.txt
|
A invalid shift found in /workspace/skyset/extractfix-libtiff/3144e57-invalid_shift/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 65176404..8e202a2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-11 Even Rouault <even.rouault at spatialys.com>
+
+ * libtiff/tif_jpeg.c: validate BitsPerSample in JPEGSetupEncode() to avoid
+ undefined behaviour caused by invalid shift exponent.
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2648
+
2017-01-11 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement various clampings
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index 6c17c388..192989a9 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -1632,6 +1632,13 @@ JPEGSetupEncode(TIFF* tif)
"Invalig horizontal/vertical sampling value");
return (0);
}
+ if( td->td_bitspersample > 16 )
+ {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "BitsPerSample %d not allowed for JPEG",
+ td->td_bitspersample);
+ return (0);
+ }
/*
* A ReferenceBlackWhite field *must* be present since the
|
3rdn4/extractfix-libtiff:6a984bf-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
6a984bf-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/6a984bf-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/6a984bf-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 48fb75d3..4ff52810 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-11-10 Even Rouault <even.rouault at spatialys.com>
+
+ * libtiff/tif_strip.c: make TIFFNumberOfStrips() return the td->td_nstrips
+ value when it is non-zero, instead of recomputing it. This is needed in
+ TIFF_STRIPCHOP mode where td_nstrips is modified. Fixes a read outsize of
+ array in tiffsplit (or other utilities using TIFFNumberOfStrips()).
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2587
+
2016-11-04 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_predic.c: fix memory leaks in error code paths added in
diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
index 1676e47d..4c46ecf5 100644
--- a/libtiff/tif_strip.c
+++ b/libtiff/tif_strip.c
@@ -63,6 +63,15 @@ TIFFNumberOfStrips(TIFF* tif)
TIFFDirectory *td = &tif->tif_dir;
uint32 nstrips;
+ /* If the value was already computed and store in td_nstrips, then return it,
+ since ChopUpSingleUncompressedStrip might have altered and resized the
+ since the td_stripbytecount and td_stripoffset arrays to the new value
+ after the initial affectation of td_nstrips = TIFFNumberOfStrips() in
+ tif_dirread.c ~line 3612.
+ See http://bugzilla.maptools.org/show_bug.cgi?id=2587 */
+ if( td->td_nstrips )
+ return td->td_nstrips;
+
nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
3rdn4/extractfix-libtiff:891b1b9-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
891b1b9-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/891b1b9-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/891b1b9-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 6be36026..91ba4e6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-20 Even Rouault <even.rouault at spatialys.com>
+
+ * tools/tiff2pdf.c: avoid potential heap-based overflow in
+ t2p_readwrite_pdf_image_tile().
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2640
+
2016-12-20 Even Rouault <even.rouault at spatialys.com>
* tools/tiff2pdf.c: avoid potential invalid memory read in
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 47d76298..db196e04 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -2895,7 +2895,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
return(0);
}
if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) {
- if (count >= 4) {
+ if (count > 4) {
int retTIFFReadRawTile;
/* Ignore EOI marker of JpegTables */
_TIFFmemcpy(buffer, jpt, count - 2);
|
3rdn4/extractfix-libtiff:8b6e80f-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
8b6e80f-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/8b6e80f-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/8b6e80f-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index ef91ab07..2dc5f4b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-21 Even Rouault <[email protected]>
+
+ * tools/thumbnail.c: fix out-of-buffer write
+ http://bugzilla.maptools.org/show_bug.cgi?id=2489 (CVE-2014-8128)
+
2014-12-21 Even Rouault <[email protected]>
* tools/thumbnail.c, tools/tiffcmp.c: only read/write TIFFTAG_GROUP3OPTIONS
diff --git a/tools/thumbnail.c b/tools/thumbnail.c
index fab63f6c..c50bbffc 100644
--- a/tools/thumbnail.c
+++ b/tools/thumbnail.c
@@ -568,7 +568,13 @@ setImage1(const uint8* br, uint32 rw, uint32 rh)
err -= limit;
sy++;
if (err >= limit)
- rows[nrows++] = br + bpr*sy;
+ {
+ /* We should perhaps error loudly, but I can't make sense of that */
+ /* code... */
+ if( nrows == 256 )
+ break;
+ rows[nrows++] = br + bpr*sy;
+ }
}
setrow(row, nrows, rows);
row += tnw;
|
3rdn4/extractfix-libtiff:9a72a69-divide_by_zero
|
/workspace/skyset/
|
extractfix-libtiff
|
9a72a69-divide_by_zero
|
/workspace/skyset/extractfix-libtiff/9a72a69-divide_by_zero/report.txt
|
A divide by zero found in /workspace/skyset/extractfix-libtiff/9a72a69-divide_by_zero/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 9dbc7a0c..5b23665b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-12-03 Even Rouault <even.rouault at spatialys.com>
+
+ * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
+ OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues.
+ Reported by Agostino Sarubbo.
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611
+
2016-12-03 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to
diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
index 1ccc3f9b..f19e8fd0 100644
--- a/libtiff/tif_ojpeg.c
+++ b/libtiff/tif_ojpeg.c
@@ -244,6 +244,7 @@ typedef enum {
typedef struct {
TIFF* tif;
+ int decoder_ok;
#ifndef LIBJPEG_ENCAP_EXTERNAL
JMP_BUF exit_jmpbuf;
#endif
@@ -722,6 +723,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
}
sp->write_curstrile++;
}
+ sp->decoder_ok = 1;
return(1);
}
@@ -784,8 +786,14 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
static int
OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{
+ static const char module[]="OJPEGDecode";
OJPEGState* sp=(OJPEGState*)tif->tif_data;
(void)s;
+ if( !sp->decoder_ok )
+ {
+ TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
+ return 0;
+ }
if (sp->libjpeg_jpeg_query_style==0)
{
if (OJPEGDecodeRaw(tif,buf,cc)==0)
|
3rdn4/extractfix-libtiff:c421b99-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
c421b99-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/c421b99-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/c421b99-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 1b0e5996..dee18813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-28 Even Rouault <even.rouault at spatialys.com>
+
+ * libtiff/tif_pixarlog.c: fix potential buffer write overrun in
+ PixarLogDecode() on corrupted/unexpected images (reported by Mathias Svensson)
+
2016-06-15 Bob Friesenhahn <[email protected]>
* libtiff/libtiff.def: Added _TIFFMultiply32 and _TIFFMultiply64
diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
index 06e8af39..cc486c54 100644
--- a/libtiff/tif_pixarlog.c
+++ b/libtiff/tif_pixarlog.c
@@ -459,6 +459,7 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op,
typedef struct {
TIFFPredictorState predict;
z_stream stream;
+ tmsize_t tbuf_size; /* only set/used on reading for now */
uint16 *tbuf;
uint16 stride;
int state;
@@ -694,6 +695,7 @@ PixarLogSetupDecode(TIFF* tif)
sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
if (sp->tbuf == NULL)
return (0);
+ sp->tbuf_size = tbuf_size;
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
sp->user_datafmt = PixarLogGuessDataFmt(td);
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) {
@@ -783,6 +785,12 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
return (0);
}
+ /* Check that we will not fill more than what was allocated */
+ if (sp->stream.avail_out > sp->tbuf_size)
+ {
+ TIFFErrorExt(tif->tif_clientdata, module, "sp->stream.avail_out > sp->tbuf_size");
+ return (0);
+ }
do {
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
if (state == Z_STREAM_END) {
|
3rdn4/extractfix-libtiff:da5a19e-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
da5a19e-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/da5a19e-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/da5a19e-heap_buffer_overflow/immutable/
|
diff --git a/tools/gif2tiff.c b/tools/gif2tiff.c
index e7ea1235..908c47f0 100644
--- a/tools/gif2tiff.c
+++ b/tools/gif2tiff.c
@@ -312,7 +312,7 @@ readextension(void)
char buf[255];
(void) getc(infile);
- while ((count = getc(infile))) {
+ while ((count = getc(infile)) && count > 0 && count < 255) {
memset(buf, 0, count);
fread(buf, 1, count, infile);
}
|
3rdn4/extractfix-libtiff:e596d4e-divide_by_zero
|
/workspace/skyset/
|
extractfix-libtiff
|
e596d4e-divide_by_zero
|
/workspace/skyset/extractfix-libtiff/e596d4e-divide_by_zero/report.txt
|
A divide by zero found in /workspace/skyset/extractfix-libtiff/e596d4e-divide_by_zero/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 5d606087..3e6642a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-15 Even Rouault <even.rouault at spatialys.com>
+
+ * tools/rgb2ycbcr.c: validate values of -v and -h parameters to
+ avoid potential divide by zero. Fixes CVE-2016-3623 (bugzilla #2569)
+
2016-08-15 Even Rouault <even.rouault at spatialys.com>
* tools/tiffcrop.c: Fix out-of-bounds write in loadImage().
diff --git a/tools/rgb2ycbcr.c b/tools/rgb2ycbcr.c
index 3829d6b2..51f42598 100644
--- a/tools/rgb2ycbcr.c
+++ b/tools/rgb2ycbcr.c
@@ -95,9 +95,13 @@ main(int argc, char* argv[])
break;
case 'h':
horizSubSampling = atoi(optarg);
+ if( horizSubSampling != 1 && horizSubSampling != 2 && horizSubSampling != 4 )
+ usage(-1);
break;
case 'v':
vertSubSampling = atoi(optarg);
+ if( vertSubSampling != 1 && vertSubSampling != 2 && vertSubSampling != 4 )
+ usage(-1);
break;
case 'r':
rowsperstrip = atoi(optarg);
|
3rdn4/extractfix-libtiff:f3069a5-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libtiff
|
f3069a5-heap_buffer_overflow
|
/workspace/skyset/extractfix-libtiff/f3069a5-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libtiff/f3069a5-heap_buffer_overflow/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 5d13f3f4..82b2580e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-12-17 Even Rouault <even.rouault at spatialys.com>
+
+ * tools/tiff2ps.c: fix 2 heap-based buffer overflows (in PSDataBW
+ and PSDataColorContig). Reported by Agostino Sarubbo.
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2633 and
+ http://bugzilla.maptools.org/show_bug.cgi?id=2634.
+
2016-12-13 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_fax3.h: revert change done on 2016-01-09 that made
diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
index ae296e91..29020670 100644
--- a/tools/tiff2ps.c
+++ b/tools/tiff2ps.c
@@ -2440,6 +2440,11 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
unsigned char *cp, c;
(void) w;
+ if( es <= 0 )
+ {
+ TIFFError(filename, "Inconsistent value of es: %d", es);
+ return;
+ }
tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);
if (tf_buf == NULL) {
TIFFError(filename, "No space for scanline buffer");
@@ -2692,7 +2697,7 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
if (alpha) {
int adjust;
- while (cc-- > 0) {
+ while (cc-- > 1) {
DOBREAK(breaklen, 1, fd);
/*
* For images with alpha, matte against
|
3rdn4/extractfix-libxml2:362b322-null_ptr_dereference
|
/workspace/skyset/
|
extractfix-libxml2
|
362b322-null_ptr_dereference
|
/workspace/skyset/extractfix-libxml2/362b322-null_ptr_dereference/report.txt
|
A null ptr dereference found in /workspace/skyset/extractfix-libxml2/362b322-null_ptr_dereference/immutable/
|
diff --git a/valid.c b/valid.c
index 9b2df56a..8075d3a0 100644
--- a/valid.c
+++ b/valid.c
@@ -1172,29 +1172,33 @@ xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob)
xmlBufferWriteCHAR(buf, content->name);
break;
case XML_ELEMENT_CONTENT_SEQ:
- if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
- (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
+ if ((content->c1 != NULL) &&
+ ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
+ (content->c1->type == XML_ELEMENT_CONTENT_SEQ)))
xmlDumpElementContent(buf, content->c1, 1);
else
xmlDumpElementContent(buf, content->c1, 0);
xmlBufferWriteChar(buf, " , ");
- if ((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
- ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) &&
- (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)))
+ if ((content->c2 != NULL) &&
+ ((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
+ ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) &&
+ (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE))))
xmlDumpElementContent(buf, content->c2, 1);
else
xmlDumpElementContent(buf, content->c2, 0);
break;
case XML_ELEMENT_CONTENT_OR:
- if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
- (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
+ if ((content->c1 != NULL) &&
+ ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
+ (content->c1->type == XML_ELEMENT_CONTENT_SEQ)))
xmlDumpElementContent(buf, content->c1, 1);
else
xmlDumpElementContent(buf, content->c1, 0);
xmlBufferWriteChar(buf, " | ");
- if ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
- ((content->c2->type == XML_ELEMENT_CONTENT_OR) &&
- (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)))
+ if ((content->c2 != NULL) &&
+ ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
+ ((content->c2->type == XML_ELEMENT_CONTENT_OR) &&
+ (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE))))
xmlDumpElementContent(buf, content->c2, 1);
else
xmlDumpElementContent(buf, content->c2, 0);
|
3rdn4/extractfix-libxml2:4ea74a4-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libxml2
|
4ea74a4-heap_buffer_overflow
|
/workspace/skyset/extractfix-libxml2/4ea74a4-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libxml2/4ea74a4-heap_buffer_overflow/immutable/
|
diff --git a/parser.c b/parser.c
index 0d8d7f2e..bd634e93 100644
--- a/parser.c
+++ b/parser.c
@@ -4076,7 +4076,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
goto error;
if ((in_space) && (normalize)) {
- while (buf[len - 1] == 0x20) len--;
+ while ((len > 0) && (buf[len - 1] == 0x20)) len--;
}
buf[len] = 0;
if (RAW == '<') {
|
3rdn4/extractfix-libxml2:cbb2716-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libxml2
|
cbb2716-heap_buffer_overflow
|
/workspace/skyset/extractfix-libxml2/cbb2716-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libxml2/cbb2716-heap_buffer_overflow/immutable/
|
diff --git a/parser.c b/parser.c
index 68e1c90f..4464e2e8 100644
--- a/parser.c
+++ b/parser.c
@@ -9825,6 +9825,7 @@ static void
xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
const xmlChar *URI, int line, int nsNr, int tlen) {
const xmlChar *name;
+ size_t curLength;
GROW;
if ((RAW != '<') || (NXT(1) != '/')) {
@@ -9833,8 +9834,11 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
}
SKIP(2);
- if ((tlen > 0) && (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
- if (ctxt->input->cur[tlen] == '>') {
+ curLength = ctxt->input->end - ctxt->input->cur;
+ if ((tlen > 0) && (curLength >= (size_t)tlen) &&
+ (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
+ if ((curLength >= (size_t)(tlen + 1)) &&
+ (ctxt->input->cur[tlen] == '>')) {
ctxt->input->cur += tlen + 1;
ctxt->input->col += tlen + 1;
goto done;
|
3rdn4/extractfix-libxml2:db07dd6-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libxml2
|
db07dd6-heap_buffer_overflow
|
/workspace/skyset/extractfix-libxml2/db07dd6-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libxml2/db07dd6-heap_buffer_overflow/immutable/
|
diff --git a/HTMLparser.c b/HTMLparser.c
index 69eed2bd..1c112cc9 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -2471,6 +2471,10 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
(*in == '_') || (*in == '-') ||
(*in == ':') || (*in == '.'))
in++;
+
+ if (in == ctxt->input->end)
+ return(NULL);
+
if ((*in > 0) && (*in < 0x80)) {
count = in - ctxt->input->cur;
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
@@ -2514,6 +2518,10 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
NEXTL(l);
c = CUR_CHAR(l);
}
+
+ if (ctxt->input->base > ctxt->input->cur - len)
+ return(NULL);
+
return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
}
diff --git a/result/HTML/758605.html b/result/HTML/758605.html
new file mode 100644
index 00000000..a085cce3
--- /dev/null
+++ b/result/HTML/758605.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><body><p>&
+</p></body></html>
diff --git a/result/HTML/758605.html.err b/result/HTML/758605.html.err
new file mode 100644
index 00000000..2b82be66
--- /dev/null
+++ b/result/HTML/758605.html.err
@@ -0,0 +1,3 @@
+./test/HTML/758605.html:1: HTML parser error : htmlParseEntityRef: no name
+ê
+ ^
diff --git a/result/HTML/758605.html.sax b/result/HTML/758605.html.sax
new file mode 100644
index 00000000..1f5cd320
--- /dev/null
+++ b/result/HTML/758605.html.sax
@@ -0,0 +1,13 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.error: htmlParseEntityRef: no name
+SAX.startElement(html)
+SAX.startElement(body)
+SAX.startElement(p)
+SAX.characters(&, 1)
+SAX.ignorableWhitespace(
+, 1)
+SAX.endElement(p)
+SAX.endElement(body)
+SAX.endElement(html)
+SAX.endDocument()
diff --git a/runtest.c b/runtest.c
index 36fbe5ac..bb74d2a8 100644
--- a/runtest.c
+++ b/runtest.c
@@ -1873,7 +1873,7 @@ pushParseTest(const char *filename, const char *result,
ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename);
xmlCtxtUseOptions(ctxt, options);
cur += 4;
- while (cur < size) {
+ do {
if (cur + 1024 >= size) {
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
@@ -1891,7 +1891,7 @@ pushParseTest(const char *filename, const char *result,
xmlParseChunk(ctxt, base + cur, 1024, 0);
cur += 1024;
}
- }
+ } while (cur < size);
doc = ctxt->myDoc;
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
|
3rdn4/extractfix-libxml2-harness:8f30bdf-heap_buffer_overflow
|
/workspace/skyset/
|
extractfix-libxml2-harness
|
8f30bdf-heap_buffer_overflow
|
/workspace/skyset/extractfix-libxml2-harness/8f30bdf-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/extractfix-libxml2-harness/8f30bdf-heap_buffer_overflow/immutable/
|
diff --git a/xmlstring.c b/xmlstring.c
index b89c9e9f..00287d4c 100644
--- a/xmlstring.c
+++ b/xmlstring.c
@@ -457,6 +457,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
return(xmlStrndup(add, len));
size = xmlStrlen(cur);
+ if (size < 0)
+ return(NULL);
ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar));
if (ret == NULL) {
xmlErrMemory(NULL, NULL);
@@ -484,14 +486,19 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
int size;
xmlChar *ret;
- if (len < 0)
+ if (len < 0) {
len = xmlStrlen(str2);
+ if (len < 0)
+ return(NULL);
+ }
if ((str2 == NULL) || (len == 0))
return(xmlStrdup(str1));
if (str1 == NULL)
return(xmlStrndup(str2, len));
size = xmlStrlen(str1);
+ if (size < 0)
+ return(NULL);
ret = (xmlChar *) xmlMalloc((size + len + 1) * sizeof(xmlChar));
if (ret == NULL) {
xmlErrMemory(NULL, NULL);
|
3rdn4/gpac:0b29a41-use_after_free
|
/workspace/skyset/
|
gpac
|
0b29a41-use_after_free
|
/workspace/skyset/gpac/0b29a41-use_after_free/report.txt
|
A use after free found in /workspace/skyset/gpac/0b29a41-use_after_free/immutable/
|
diff --git a/src/bifs/field_decode.c b/src/bifs/field_decode.c
index 5537da7d3..65d045b02 100644
--- a/src/bifs/field_decode.c
+++ b/src/bifs/field_decode.c
@@ -427,64 +427,71 @@ GF_Err BD_DecMFFieldVec(GF_BifsDecoder * codec, GF_BitStream *bs, GF_Node *node,
e = gf_bifs_dec_sf_field(codec, bs, node, &sffield, GF_FALSE);
if (e) return e;
}
- } else {
- last = NULL;
- for (i=0; i<nbFields; i++) {
- GF_Node *new_node = gf_bifs_dec_node(codec, bs, field->NDTtype);
- if (new_node) {
- e = gf_node_register(new_node, is_mem_com ? NULL : node);
- if (e) return e;
-
- if (node) {
- /*special case for QP, register as the current QP*/
- if (gf_node_get_tag(new_node) == TAG_MPEG4_QuantizationParameter) {
- qp_local = ((M_QuantizationParameter *)new_node)->isLocal;
- /*we have a QP in the same scope, remove previous
- NB: we assume this is the right behavior, the spec doesn't say
- whether QP is cumulative or not*/
- if (qp_on) gf_bifs_dec_qp_remove(codec, GF_FALSE);
+ return GF_OK;
+ }
- e = gf_bifs_dec_qp_set(codec, new_node);
- if (e) return e;
- qp_on = 1;
- if (qp_local) qp_local = 2;
- if (codec->force_keep_qp) {
- e = gf_node_list_add_child_last(field->far_ptr, new_node, &last);
- if (e) return e;
- } else {
- gf_node_register(new_node, NULL);
- gf_node_unregister(new_node, node);
- }
- } else {
+ e = GF_OK;
+ last = NULL;
+ for (i=0; i<nbFields; i++) {
+ GF_Node *new_node = gf_bifs_dec_node(codec, bs, field->NDTtype);
+ if (new_node) {
+ e = gf_node_register(new_node, is_mem_com ? NULL : node);
+ if (e) goto exit;
+
+ if (node) {
+ /*special case for QP, register as the current QP*/
+ if (gf_node_get_tag(new_node) == TAG_MPEG4_QuantizationParameter) {
+ qp_local = ((M_QuantizationParameter *)new_node)->isLocal;
+ /*we have a QP in the same scope, remove previous
+ NB: we assume this is the right behavior, the spec doesn't say
+ whether QP is cumulative or not*/
+ if (qp_on) gf_bifs_dec_qp_remove(codec, GF_FALSE);
+
+ e = gf_bifs_dec_qp_set(codec, new_node);
+ if (e) goto exit;
+ qp_on = 1;
+ if (qp_local) qp_local = 2;
+ if (codec->force_keep_qp) {
e = gf_node_list_add_child_last(field->far_ptr, new_node, &last);
- if (e) return e;
+ if (e) goto exit;
+ } else {
+ gf_node_register(new_node, NULL);
+ gf_node_unregister(new_node, node);
}
+ } else {
+ e = gf_node_list_add_child_last(field->far_ptr, new_node, &last);
+ if (e) goto exit;
}
- /*proto coding*/
- else if (codec->pCurrentProto) {
- /*TO DO: what happens if this is a QP node on the interface ?*/
- e = gf_node_list_add_child_last( (GF_ChildNodeItem **)field->far_ptr, new_node, &last);
- if (e) return e;
- }
- } else {
- return codec->LastError ? codec->LastError : GF_NON_COMPLIANT_BITSTREAM;
}
+ /*proto coding*/
+ else if (codec->pCurrentProto) {
+ /*TO DO: what happens if this is a QP node on the interface ?*/
+ e = gf_node_list_add_child_last( (GF_ChildNodeItem **)field->far_ptr, new_node, &last);
+ if (e)goto exit;
+ }
+ } else {
+ e = codec->LastError ? codec->LastError : GF_NON_COMPLIANT_BITSTREAM;
+ goto exit;
}
- /*according to the spec, the QP applies to the current node itself, not just children.
- If IsLocal is TRUE remove the node*/
- if (qp_on && qp_local) {
- if (qp_local == 2) {
+ }
+
+exit:
+
+ /*according to the spec, the QP applies to the current node itself, not just children.
+ If IsLocal is TRUE remove the node*/
+ if (qp_on && qp_local) {
+ if (qp_local == 2) {
// qp_local = 1;
- } else {
- //ask to get rid of QP and reactivate if we had a QP when entering the node
- gf_bifs_dec_qp_remove(codec, initial_qp);
+ } else {
+ //ask to get rid of QP and reactivate if we had a QP when entering the node
+ gf_bifs_dec_qp_remove(codec, initial_qp);
// qp_local = 0;
- }
}
}
+
/*finally delete the QP if any (local or not) as we get out of this node*/
if (qp_on) gf_bifs_dec_qp_remove(codec, GF_TRUE);
- return GF_OK;
+ return e;
}
|
3rdn4/gpac:112767e-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
112767e-heap_out_of_bound
|
/workspace/skyset/gpac/112767e-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/112767e-heap_out_of_bound/immutable/
|
diff --git a/src/media_tools/avilib.c b/src/media_tools/avilib.c
index 459ff8043..27cd81133 100644
--- a/src/media_tools/avilib.c
+++ b/src/media_tools/avilib.c
@@ -2941,6 +2941,7 @@ int AVI_read_frame(avi_t *AVI, u8 *vidbuf, int *keyframe)
}
gf_fseek(AVI->fdes, AVI->video_index[AVI->video_pos].pos, SEEK_SET);
+ AVI->video_pos++;
if (avi_read(AVI->fdes,vidbuf,n) != (u32) n)
{
@@ -2948,8 +2949,6 @@ int AVI_read_frame(avi_t *AVI, u8 *vidbuf, int *keyframe)
return -1;
}
- AVI->video_pos++;
-
return n;
}
|
3rdn4/gpac:1b77837-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
1b77837-heap_out_of_bound
|
/workspace/skyset/gpac/1b77837-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/1b77837-heap_out_of_bound/immutable/
|
diff --git a/src/media_tools/mpegts.c b/src/media_tools/mpegts.c
index 30fb2bb3f..7deabb630 100644
--- a/src/media_tools/mpegts.c
+++ b/src/media_tools/mpegts.c
@@ -946,6 +946,11 @@ static void gf_m2ts_process_tdt_tot(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *tdt
return;
}
+ if (data_size < 5) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Section data size too small to read date (len: %u)\n", data_size));
+ return;
+ }
+
/*UTC_time - see annex C of DVB-SI ETSI EN 300468*/
/* decodes an Modified Julian Date (MJD) into a Co-ordinated Universal Time (UTC)
See annex C of DVB-SI ETSI EN 300468 */
|
3rdn4/gpac:3ffe59c-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
3ffe59c-heap_out_of_bound
|
/workspace/skyset/gpac/3ffe59c-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/3ffe59c-heap_out_of_bound/immutable/
|
diff --git a/src/media_tools/av_parsers.c b/src/media_tools/av_parsers.c
index 83e939aba..5582d47a4 100644
--- a/src/media_tools/av_parsers.c
+++ b/src/media_tools/av_parsers.c
@@ -8500,7 +8500,15 @@ static s32 gf_hevc_read_pps_bs_internal(GF_BitStream *bs, HEVCState *hevc)
pps->entropy_coding_sync_enabled_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_tile_columns_minus1");
+ if (pps->num_tile_columns > 22) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid num_tile_columns %u\n", pps->num_tile_columns));
+ return -1;
+ }
pps->num_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_tile_rows_minus1");
+ if (pps->num_tile_rows > 20) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid num_tile_rows %u\n", pps->num_tile_rows));
+ return -1;
+ }
pps->uniform_spacing_flag = gf_bs_read_int_log(bs, 1, "uniform_spacing_flag");
if (!pps->uniform_spacing_flag) {
for (i = 0; i < pps->num_tile_columns - 1; i++) {
|
3rdn4/gpac:4607052-double_free
|
/workspace/skyset/
|
gpac
|
4607052-double_free
|
/workspace/skyset/gpac/4607052-double_free/report.txt
|
A double free found in /workspace/skyset/gpac/4607052-double_free/immutable/
|
diff --git a/src/filters/isoffin_read_ch.c b/src/filters/isoffin_read_ch.c
index 257f5c603..bd9640068 100644
--- a/src/filters/isoffin_read_ch.c
+++ b/src/filters/isoffin_read_ch.c
@@ -495,6 +495,7 @@ void isor_reader_get_sample(ISOMChannel *ch)
if (ch->pck) {
gf_filter_pck_discard(ch->pck);
ch->pck = NULL;
+ ch->static_sample->alloc_size = ch->static_sample->dataLength = 0;
}
isor_reader_get_sample(ch);
return;
|
3rdn4/gpac:4925c40-use_after_free
|
/workspace/skyset/
|
gpac
|
4925c40-use_after_free
|
/workspace/skyset/gpac/4925c40-use_after_free/report.txt
|
A use after free found in /workspace/skyset/gpac/4925c40-use_after_free/immutable/
|
diff --git a/src/utils/xml_parser.c b/src/utils/xml_parser.c
index 2373ea63f..e372b43fe 100644
--- a/src/utils/xml_parser.c
+++ b/src/utils/xml_parser.c
@@ -492,7 +492,8 @@ static Bool xml_sax_parse_attribute(GF_SAXParser *parser)
att->val_start = parser->current_pos + 2;
break;
default:
- break;
+ // garbage char before value separator -> error
+ goto att_retry;
}
parser->current_pos++;
if (parser->att_sep) break;
@@ -503,6 +504,10 @@ static Bool xml_sax_parse_attribute(GF_SAXParser *parser)
att_retry:
assert(parser->att_sep);
+ if (!parser->att_sep) {
+ format_sax_error(parser, parser->current_pos, "Invalid character %c before attribute value separator", parser->buffer[parser->current_pos]);
+ return GF_TRUE;
+ }
sep = strchr(parser->buffer + parser->current_pos, parser->att_sep);
if (!sep || !sep[1]) return GF_TRUE;
@@ -1277,7 +1282,7 @@ GF_Err gf_xml_sax_parse_file(GF_SAXParser *parser, const char *fileName, gf_xml_
if (parser->on_progress) parser->on_progress(parser->sax_cbck, parser->file_pos, parser->file_size);
}
gf_blob_release(fileName);
-
+
parser->elt_start_pos = parser->elt_end_pos = 0;
parser->elt_name_start = parser->elt_name_end = 0;
parser->att_name_start = 0;
@@ -2458,7 +2463,7 @@ GF_Err gf_xml_get_element_check_namespace(const GF_XMLNode *n, const char *expec
const char *ns;
ns = strstr(att->name, ":");
if (!ns) continue;
-
+
if (!strncmp(att->name, "xmlns", 5)) {
if (!strcmp(ns+1, n->ns)) {
return GF_OK;
|
3rdn4/gpac:49cb88a-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
49cb88a-heap_out_of_bound
|
/workspace/skyset/gpac/49cb88a-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/49cb88a-heap_out_of_bound/immutable/
|
diff --git a/src/filters/reframe_mhas.c b/src/filters/reframe_mhas.c
index 1b920c717..9f6fa5994 100644
--- a/src/filters/reframe_mhas.c
+++ b/src/filters/reframe_mhas.c
@@ -542,7 +542,7 @@ GF_Err mhas_dmx_process(GF_Filter *filter)
remain=0;
break;
}
- if ((hdr_start[1]==0x01) && (hdr_start[2]==0xA5)) {
+ if ( (u32)(hdr_start-start)+3 <= remain && (hdr_start[1]==0x01) && (hdr_start[2]==0xA5)) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[MHASDmx] Sync found !\n"));
ctx->nosync = GF_FALSE;
break;
|
3rdn4/gpac:50a60b0-null_pointer_deref
|
/workspace/skyset/
|
gpac
|
50a60b0-null_pointer_deref
|
/workspace/skyset/gpac/50a60b0-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/gpac/50a60b0-null_pointer_deref/immutable/
|
diff --git a/src/filters/reframe_rawpcm.c b/src/filters/reframe_rawpcm.c
index 37decc00e..406c6638d 100644
--- a/src/filters/reframe_rawpcm.c
+++ b/src/filters/reframe_rawpcm.c
@@ -360,6 +360,14 @@ GF_Err pcmreframe_process(GF_Filter *filter)
}
wav_ok = GF_FALSE;
}
+ if (!ctx->ch) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[PCMReframe] Channel count %d invalid in wave\n", ctx->ch));
+ wav_ok = GF_FALSE;
+ }
+ if (!ctx->sr) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[PCMReframe] Samplerate %d invalid in wave\n", ctx->sr));
+ wav_ok = GF_FALSE;
+ }
ctx->wav_hdr_size = (u32) gf_bs_get_position(bs);
|
3rdn4/gpac:514a3af-stack_out_of_bound
|
/workspace/skyset/
|
gpac
|
514a3af-stack_out_of_bound
|
/workspace/skyset/gpac/514a3af-stack_out_of_bound/report.txt
|
A stack out of bound found in /workspace/skyset/gpac/514a3af-stack_out_of_bound/immutable/
|
diff --git a/src/scenegraph/vrml_proto.c b/src/scenegraph/vrml_proto.c
index df30ed0df..02b92b576 100644
--- a/src/scenegraph/vrml_proto.c
+++ b/src/scenegraph/vrml_proto.c
@@ -1292,7 +1292,10 @@ Bool gf_sg_proto_field_is_sftime_offset(GF_Node *node, GF_FieldInfo *field)
gf_node_get_field(r->ToNode, r->ToField.fieldIndex, &inf);
/*IS to another proto*/
- if (r->ToNode->sgprivate->tag == TAG_ProtoNode) return gf_sg_proto_field_is_sftime_offset(r->ToNode, &inf);
+ if (r->ToNode->sgprivate->tag == TAG_ProtoNode) {
+ if (r->ToNode==node) continue;
+ return gf_sg_proto_field_is_sftime_offset(r->ToNode, &inf);
+ }
/*IS to a startTime/stopTime field*/
if (!stricmp(inf.name, "startTime") || !stricmp(inf.name, "stopTime")) return 1;
}
|
3rdn4/gpac:6f28c4c-null_pointer_deref
|
/workspace/skyset/
|
gpac
|
6f28c4c-null_pointer_deref
|
/workspace/skyset/gpac/6f28c4c-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/gpac/6f28c4c-null_pointer_deref/immutable/
|
diff --git a/src/isomedia/movie_fragments.c b/src/isomedia/movie_fragments.c
index b742078d1..41d0717a4 100644
--- a/src/isomedia/movie_fragments.c
+++ b/src/isomedia/movie_fragments.c
@@ -2876,7 +2876,8 @@ GF_Err gf_isom_fragment_add_sample_ex(GF_ISOFile *movie, GF_ISOTrackID TrackID,
//rewrite OD frames
if (traf->trex->track->Media->handler->handlerType == GF_ISOM_MEDIA_OD) {
//this may fail if dependencies are not well done ...
- Media_ParseODFrame(traf->trex->track->Media, sample, &od_sample);
+ GF_Err e = Media_ParseODFrame(traf->trex->track->Media, sample, &od_sample);
+ if (!od_sample) return e;
sample = od_sample;
}
|
3rdn4/gpac:78f5269-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
78f5269-heap_out_of_bound
|
/workspace/skyset/gpac/78f5269-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/78f5269-heap_out_of_bound/immutable/
|
diff --git a/src/isomedia/box_code_base.c b/src/isomedia/box_code_base.c
index 0048d9eab..9eee78da6 100644
--- a/src/isomedia/box_code_base.c
+++ b/src/isomedia/box_code_base.c
@@ -10663,6 +10668,7 @@ GF_Err trgt_box_write(GF_Box *s, GF_BitStream *bs)
GF_Err e;
GF_TrackGroupTypeBox *ptr = (GF_TrackGroupTypeBox *) s;
if (!s) return GF_BAD_PARAM;
+ if (ptr->group_type == GF_ISOM_BOX_TYPE_UUID) return GF_BAD_PARAM;
s->type = ptr->group_type;
e = gf_isom_full_box_write(s, bs);
s->type = GF_ISOM_BOX_TYPE_TRGT;
|
3rdn4/gpac:7a6f636-stack_out_of_bound
|
/workspace/skyset/
|
gpac
|
7a6f636-stack_out_of_bound
|
/workspace/skyset/gpac/7a6f636-stack_out_of_bound/report.txt
|
A stack out of bound found in /workspace/skyset/gpac/7a6f636-stack_out_of_bound/immutable/
|
diff --git a/src/media_tools/mpegts.c b/src/media_tools/mpegts.c
index b4fb08b44..a544d4d5a 100644
--- a/src/media_tools/mpegts.c
+++ b/src/media_tools/mpegts.c
@@ -2468,7 +2468,7 @@ static void gf_m2ts_get_adaptation_field(GF_M2TS_Demuxer *ts, GF_M2TS_Adaptation
break;
}
gf_bs_read_data(bs, _url, url_len);
- _url[url_len] = 0;
+ _url[url_len >= GF_ARRAY_LENGTH(URL) ? GF_ARRAY_LENGTH(URL)-1 : url_len] = 0;
}
temi_loc.external_URL = URL;
|
3rdn4/gpac:7e2cb01-use_after_free
|
/workspace/skyset/
|
gpac
|
7e2cb01-use_after_free
|
/workspace/skyset/gpac/7e2cb01-use_after_free/report.txt
|
A use after free found in /workspace/skyset/gpac/7e2cb01-use_after_free/immutable/
|
diff --git a/src/odf/descriptors.c b/src/odf/descriptors.c
index 0d42ff2df..913d8e27a 100644
--- a/src/odf/descriptors.c
+++ b/src/odf/descriptors.c
@@ -1395,12 +1395,12 @@ GF_VVCConfig *gf_odf_vvc_cfg_read_bs(GF_BitStream *bs)
gf_list_add(cfg->param_array, ar);
break;
default:
- GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[VVC] Invalid NALU type in vvcC - ignoring\n", ar->nalus));
+ GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[VVC] Invalid NALU type %d in vvcC - ignoring\n", ar->type));
gf_free(ar);
break;
}
- if ((ar->type != GF_VVC_NALU_DEC_PARAM) && (ar->type != GF_VVC_NALU_OPI))
+ if (!valid || ((ar->type != GF_VVC_NALU_DEC_PARAM) && (ar->type != GF_VVC_NALU_OPI)))
nalucount = gf_bs_read_int(bs, 16);
else
nalucount = 1;
|
3rdn4/gpac:7e2e92f-use_after_free
|
/workspace/skyset/
|
gpac
|
7e2e92f-use_after_free
|
/workspace/skyset/gpac/7e2e92f-use_after_free/report.txt
|
A use after free found in /workspace/skyset/gpac/7e2e92f-use_after_free/immutable/
|
diff --git a/src/filters/mux_isom.c b/src/filters/mux_isom.c
index 4044ef11f..e9bc42231 100644
--- a/src/filters/mux_isom.c
+++ b/src/filters/mux_isom.c
@@ -3991,6 +3991,7 @@ static GF_Err mp4_mux_configure_pid(GF_Filter *filter, GF_FilterPid *pid, Bool i
TrackWriter *tkw = gf_filter_pid_get_udta(pid);
if (tkw) {
gf_list_del_item(ctx->tracks, tkw);
+ if (ctx->ref_tkw == tkw) ctx->ref_tkw = gf_list_get(ctx->tracks, 0);
gf_free(tkw);
}
//removing last pid
|
3rdn4/gpac:7edc40f-null_pointer_deref
|
/workspace/skyset/
|
gpac
|
7edc40f-null_pointer_deref
|
/workspace/skyset/gpac/7edc40f-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/gpac/7edc40f-null_pointer_deref/immutable/
|
diff --git a/src/filters/isoffin_load.c b/src/filters/isoffin_load.c
index 8a56b593f..1304e899a 100644
--- a/src/filters/isoffin_load.c
+++ b/src/filters/isoffin_load.c
@@ -89,7 +89,7 @@ static void isor_get_chapters(GF_ISOFile *file, GF_FilterPid *opid)
GF_TextSample *txt = gf_isom_parse_text_sample(bs);
if (txt) {
times.vals[i] = (u32) s->DTS;
- names.vals[i] = gf_strdup(txt->text);
+ names.vals[i] = gf_strdup(txt->text ? txt->text : "");
gf_isom_delete_text_sample(txt);
}
gf_bs_del(bs);
@@ -1105,7 +1105,7 @@ props_done:
gf_odf_desc_del((GF_Descriptor *)lang_desc);
lang_desc = NULL;
}
-
+
if (read->smode != MP4DMX_SINGLE) {
if ((codec_id==GF_CODECID_LHVC) || (codec_id==GF_CODECID_HEVC)) {
Bool signal_lhv = (read->smode==MP4DMX_SPLIT) ? GF_TRUE : GF_FALSE;
@@ -1750,7 +1750,7 @@ GF_Err isor_declare_objects(ISOMReader *read)
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[IsoMedia] No suitable tracks in file\n"));
return GF_NOT_SUPPORTED;
}
-
+
/*if cover art, declare a video pid*/
if (gf_isom_apple_get_tag(read->mov, GF_ISOM_ITUNE_COVER_ART, &tag, &tlen)==GF_OK) {
@@ -1853,7 +1853,7 @@ retry:
if (read->itemid)
gf_filter_pid_set_property(pid, GF_PROP_PID_ITEM_ID, &PROP_UINT(item_id));
-
+
if ((item_codecid==GF_CODECID_HEVC) && gf_isom_meta_item_has_ref(read->mov, GF_TRUE, 0, item_id, GF_ISOM_REF_TBAS)) {
gf_filter_pid_set_property(pid, GF_PROP_PID_TILE_BASE, &PROP_BOOL(GF_TRUE));
}
@@ -1948,6 +1948,3 @@ retry:
}
#endif // !defined(GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_MP4DMX)
-
-
-
diff --git a/src/filters/mux_isom.c b/src/filters/mux_isom.c
index 57e9e7834..29bdbb64b 100644
--- a/src/filters/mux_isom.c
+++ b/src/filters/mux_isom.c
@@ -1027,7 +1027,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_FILE) );
mux_assign_mime_file_ext(pid, ctx->opid, ISOM_FILE_EXT, ISOM_FILE_MIME, NULL);
-
+
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DASH_MODE, NULL);
//we dispatch timing in milliseconds
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(1000));
@@ -1080,7 +1080,7 @@ static GF_Err mp4_mux_setup_pid(GF_Filter *filter, GF_FilterPid *pid, Bool is_tr
GF_FilterEvent evt;
GF_SAFEALLOC(tkw, TrackWriter);
if (!tkw) return GF_OUT_OF_MEM;
-
+
gf_list_add(ctx->tracks, tkw);
tkw->ipid = pid;
tkw->fake_track = !is_true_pid;
@@ -2615,7 +2615,7 @@ sample_entry_setup:
return e;
}
}
-
+
if (xps_inband) {
//this will cleanup all PS in avcC / svcC
gf_isom_avc_set_inband_config(ctx->file, tkw->track_num, tkw->stsd_idx, (xps_inband==XPS_IB_BOTH) ? GF_TRUE : GF_FALSE);
@@ -3213,7 +3213,7 @@ sample_entry_setup:
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MP4Mux] muxing unknown codec ID %s, using generic sample entry with 4CC \"%s\"\n", gf_codecid_name(codec_id), gf_4cc_to_str(m_subtype) ));
}
}
-
+
e = gf_isom_new_generic_sample_description(ctx->file, tkw->track_num, (char *)src_url, NULL, &udesc, &tkw->stsd_idx);
if (gpac_meta_dsi) gf_free(gpac_meta_dsi);
@@ -3762,7 +3762,7 @@ sample_entry_done:
if (add_chap) {
gf_isom_add_chapter(ctx->file, 0, start_time, p2->value.string_list.vals[j]);
}
- if (add_tk) {
+ if (add_tk && p2->value.string_list.vals[j]) {
GF_TextSample tx;
memset(&tx, 0, sizeof(tx));
tx.text = p2->value.string_list.vals[j];
@@ -4363,7 +4363,7 @@ static GF_Err mp4_mux_cenc_update(GF_MP4MuxCtx *ctx, TrackWriter *tkw, GF_Filter
tkw->has_seig = GF_TRUE;
}
} else {
-
+
e = GF_OK;
//multikey ALWAYS uses seig
if (tkw->cenc_ki->value.data.ptr[0])
@@ -5014,7 +5014,7 @@ static GF_Err mp4_mux_process_sample(GF_MP4MuxCtx *ctx, TrackWriter *tkw, GF_Fil
tkw->gdr_type = sap_type;
}
}
-
+
subs = gf_filter_pck_get_property(pck, GF_PROP_PCK_SUBS);
if (subs) {
//if no AUDelim nal and inband header injection, push new subsample
@@ -7107,7 +7107,7 @@ retry_pck:
if (blocking_refs && has_ready) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MP4Mux] Blocking input packets present, aborting initial timing sync\n"));
}
- //this may be quite long until we have a packet in case input pid is video encoding
+ //this may be quite long until we have a packet in case input pid is video encoding
else if (ctx->config_retry_start && (gf_sys_clock() - ctx->config_retry_start > 10000)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MP4Mux] No input packets present on one or more inputs for more than 10s, aborting initial timing sync\n"));
} else {
@@ -7908,7 +7908,7 @@ static GF_Err mp4_mux_done(GF_MP4MuxCtx *ctx, Bool is_final)
}
gf_isom_purge_track_reference(ctx->file, tkw->track_num);
-
+
if (ctx->importer && ctx->dur.num && ctx->dur.den) {
u64 mdur = gf_isom_get_media_duration(ctx->file, tkw->track_num);
u64 pdur = gf_isom_get_track_duration(ctx->file, tkw->track_num);
@@ -8392,4 +8392,3 @@ const GF_FilterRegister *mp4mx_register(GF_FilterSession *session)
return NULL;
}
#endif // GPAC_DISABLE_ISOM_WRITE
-
diff --git a/src/isomedia/media.c b/src/isomedia/media.c
index 2a2d6140f..5c1941ae7 100644
--- a/src/isomedia/media.c
+++ b/src/isomedia/media.c
@@ -392,6 +392,8 @@ GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bo
return GF_ISOM_INVALID_MEDIA;
} else {
GF_LASeRSampleEntryBox*ptr = (GF_LASeRSampleEntryBox*)entry;
+ if (!ptr || !ptr->lsr_config || !ptr->lsr_config->hdr_size)
+ return GF_ISOM_INVALID_MEDIA;
esd = gf_odf_desc_esd_new(2);
*out_esd = esd;
esd->decoderConfig->streamType = GF_STREAM_SCENE;
@@ -1071,7 +1073,7 @@ GF_Err Media_AddSample(GF_MediaBox *mdia, u64 data_offset, const GF_ISOSample *s
e = stbl_AddChunkOffset(mdia, sampleNumber, StreamDescIndex, data_offset, sample->nb_pack);
if (e) return e;
}
-
+
if (!syncShadowNumber) return GF_OK;
if (!stbl->ShadowSync) {
stbl->ShadowSync = (GF_ShadowSyncBox *) gf_isom_box_new_parent(&stbl->child_boxes, GF_ISOM_BOX_TYPE_STSH);
diff --git a/src/isomedia/tx3g.c b/src/isomedia/tx3g.c
index 5891277ad..dab220d22 100644
--- a/src/isomedia/tx3g.c
+++ b/src/isomedia/tx3g.c
@@ -102,12 +102,14 @@ GF_Err gf_isom_get_text_description(GF_ISOFile *movie, u32 trackNumber, u32 desc
(*out_desc)->displayFlags = txt->displayFlags;
(*out_desc)->vert_justif = txt->vertical_justification;
(*out_desc)->horiz_justif = txt->horizontal_justification;
- (*out_desc)->font_count = txt->font_table->entry_count;
- (*out_desc)->fonts = (GF_FontRecord *) gf_malloc(sizeof(GF_FontRecord) * txt->font_table->entry_count);
- for (i=0; i<txt->font_table->entry_count; i++) {
- (*out_desc)->fonts[i].fontID = txt->font_table->fonts[i].fontID;
- if (txt->font_table->fonts[i].fontName)
- (*out_desc)->fonts[i].fontName = gf_strdup(txt->font_table->fonts[i].fontName);
+ if (txt->font_table && txt->font_table->entry_count) {
+ (*out_desc)->font_count = txt->font_table->entry_count;
+ (*out_desc)->fonts = (GF_FontRecord *) gf_malloc(sizeof(GF_FontRecord) * txt->font_table->entry_count);
+ for (i=0; i<txt->font_table->entry_count; i++) {
+ (*out_desc)->fonts[i].fontID = txt->font_table->fonts[i].fontID;
+ if (txt->font_table->fonts[i].fontName)
+ (*out_desc)->fonts[i].fontName = gf_strdup(txt->font_table->fonts[i].fontName);
+ }
}
}
return GF_OK;
@@ -663,9 +665,12 @@ GF_TextSample *gf_isom_parse_text_sample(GF_BitStream *bs)
}
while (gf_bs_available(bs)) {
- GF_Box *a;
+ GF_Box *a = NULL;
GF_Err e = gf_isom_box_parse(&a, bs);
- if (e) break;
+ if (e) {
+ if (a) gf_isom_box_del(a);
+ break;
+ }
switch (a->type) {
case GF_ISOM_BOX_TYPE_STYL:
|
3rdn4/gpac:89a80ca-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
89a80ca-heap_out_of_bound
|
/workspace/skyset/gpac/89a80ca-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/89a80ca-heap_out_of_bound/immutable/
|
diff --git a/include/gpac/internal/media_dev.h b/include/gpac/internal/media_dev.h
index c2c2833db..f722dd99a 100644
--- a/include/gpac/internal/media_dev.h
+++ b/include/gpac/internal/media_dev.h
@@ -464,7 +464,7 @@ typedef struct RepFormat
typedef struct
{
u16 avg_bit_rate, max_bit_rate, avg_pic_rate;
- u8 constand_pic_rate_idc;
+ u8 constant_pic_rate_idc;
} HEVC_RateInfo;
@@ -483,6 +483,7 @@ typedef struct
HEVC_ProfileTierLevel ptl;
HEVC_SublayerPTL sub_ptl[8];
+ //this is not parsed yet (in VPS VUI)
HEVC_RateInfo rates[8];
diff --git a/src/filters/reframe_nalu.c b/src/filters/reframe_nalu.c
index b680597d9..165b0f136 100644
--- a/src/filters/reframe_nalu.c
+++ b/src/filters/reframe_nalu.c
@@ -1018,7 +1018,7 @@ static void naludmx_create_hevc_decoder_config(GF_NALUDmxCtx *ctx, u8 **dsi, u32
if (!i) {
hvcc->avgFrameRate = lvcc->avgFrameRate = vps->rates[0].avg_pic_rate;
- hvcc->constantFrameRate = lvcc->constantFrameRate = vps->rates[0].constand_pic_rate_idc;
+ hvcc->constantFrameRate = lvcc->constantFrameRate = vps->rates[0].constant_pic_rate_idc;
hvcc->numTemporalLayers = lvcc->numTemporalLayers = vps->max_sub_layers;
hvcc->temporalIdNested = lvcc->temporalIdNested = vps->temporal_id_nesting;
}
@@ -1183,7 +1183,7 @@ static void naludmx_create_vvc_decoder_config(GF_NALUDmxCtx *ctx, u8 **dsi, u32
if (!i) {
cfg->avgFrameRate = vps->rates[0].avg_pic_rate;
- cfg->constantFrameRate = vps->rates[0].constand_pic_rate_idc;
+ cfg->constantFrameRate = vps->rates[0].constant_pic_rate_idc;
cfg->numTemporalLayers = vps->max_sub_layers;
}
if (!ctx->analyze)
diff --git a/src/media_tools/av_parsers.c b/src/media_tools/av_parsers.c
index 552be943e..f781cb6f3 100644
--- a/src/media_tools/av_parsers.c
+++ b/src/media_tools/av_parsers.c
@@ -8195,8 +8195,10 @@ static s32 gf_hevc_read_sps_bs_internal(GF_BitStream *bs, HEVCState *hevc, u8 la
sps->update_rep_format_flag = gf_bs_read_int_log(bs, 1, "update_rep_format_flag");
if (sps->update_rep_format_flag) {
sps->rep_format_idx = gf_bs_read_int_log(bs, 8, "rep_format_idx");
- }
- else {
+ if (sps->rep_format_idx>15) {
+ return -1;
+ }
+ } else {
sps->rep_format_idx = vps->rep_format_idx[layer_id];
}
sps->width = vps->rep_formats[sps->rep_format_idx].pic_width_luma_samples;
|
3rdn4/gpac:8db20cb-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
8db20cb-heap_out_of_bound
|
/workspace/skyset/gpac/8db20cb-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/8db20cb-heap_out_of_bound/immutable/
|
diff --git a/src/isomedia/box_code_base.c b/src/isomedia/box_code_base.c
index baf07ff35..9a9ad09b4 100644
--- a/src/isomedia/box_code_base.c
+++ b/src/isomedia/box_code_base.c
@@ -9983,6 +9983,9 @@ static void *sgpd_parse_entry(u32 grouping_type, GF_BitStream *bs, s32 bytes_in_
}
return ptr;
}
+ case 0:
+ GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] sgpd entry null grouping_type is invalid\n") );
+ return NULL;
default:
break;
}
|
3rdn4/gpac:8f3088b-null_pointer_deref
|
/workspace/skyset/
|
gpac
|
8f3088b-null_pointer_deref
|
/workspace/skyset/gpac/8f3088b-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/gpac/8f3088b-null_pointer_deref/immutable/
|
diff --git a/src/utils/xml_parser.c b/src/utils/xml_parser.c
index 49df33816..11f6f2f5c 100644
--- a/src/utils/xml_parser.c
+++ b/src/utils/xml_parser.c
@@ -704,6 +704,8 @@ static void xml_sax_parse_entity(GF_SAXParser *parser)
}
}
if (ent_name) gf_free(ent_name);
+ if (ent && !ent->value)
+ parser->sax_state = SAX_STATE_SYNTAX_ERROR;
xml_sax_store_text(parser, i);
}
@@ -968,7 +970,7 @@ exit:
static GF_Err xml_sax_append_string(GF_SAXParser *parser, char *string)
{
u32 size = parser->line_size;
- u32 nl_size = (u32) strlen(string);
+ u32 nl_size = string ? (u32) strlen(string) : 0;
if (!nl_size) return GF_OK;
|
3rdn4/gpac:94cf5b1-stack_out_of_bound
|
/workspace/skyset/
|
gpac
|
94cf5b1-stack_out_of_bound
|
/workspace/skyset/gpac/94cf5b1-stack_out_of_bound/report.txt
|
A stack out of bound found in /workspace/skyset/gpac/94cf5b1-stack_out_of_bound/immutable/
|
diff --git a/src/bifs/unquantize.c b/src/bifs/unquantize.c
index a4bfcbfbb..a43df12f0 100644
--- a/src/bifs/unquantize.c
+++ b/src/bifs/unquantize.c
@@ -292,6 +292,7 @@ GF_Err Q_DecCoordOnUnitSphere(GF_BifsDecoder *codec, GF_BitStream *bs, u32 NbBit
if(NbComp == 2) dir -= 2 * gf_bs_read_int(bs, 1);
orient = gf_bs_read_int(bs, 2);
+ if ((orient==3) && (NbComp==2)) return GF_NON_COMPLIANT_BITSTREAM;
for(i=0; i<NbComp; i++) {
value = gf_bs_read_int(bs, NbBits) - (1 << (NbBits-1) );
@@ -341,7 +342,7 @@ GF_Err Q_DecRotation(GF_BifsDecoder *codec, GF_BitStream *bs, u32 NbBits, void *
//parses a Normal vec
GF_Err Q_DecNormal(GF_BifsDecoder *codec, GF_BitStream *bs, u32 NbBits, void *field_ptr)
{
- Fixed comp[3];
+ Fixed comp[4];
SFVec3f v;
GF_Err e;
e = Q_DecCoordOnUnitSphere(codec, bs, NbBits, 2, comp);
|
3rdn4/gpac:a6b6408-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
a6b6408-heap_out_of_bound
|
/workspace/skyset/gpac/a6b6408-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/a6b6408-heap_out_of_bound/immutable/
|
diff --git a/include/gpac/bitstream.h b/include/gpac/bitstream.h
index a1d439a71..ee7436b4c 100644
--- a/include/gpac/bitstream.h
+++ b/include/gpac/bitstream.h
@@ -624,6 +624,26 @@ Gets the current cookie on the bitstream
*/
u64 gf_bs_get_cookie(GF_BitStream *bs);
+
+/*!
+\brief Marks overflow access
+
+Marks the bitstream as overflown (reading outside of buffer range). Marking is done automatically when reading but can be forced using this function.
+
+\param bs the target bitstream
+\param reset if GF_TRUE, reset overflown state, otherwise mark as overflown
+ */
+void gf_bs_mark_overflow(GF_BitStream *bs, Bool reset);
+
+/*!
+\brief Gets overflow state
+
+Gets overflow state of the bitstream
+\param bs the target bitstream
+\return 2 if an overflow was marked by user using \ref gf_bs_mark_overflow, 1 if an overflow occured, 0 otherwise
+ */
+u32 gf_bs_is_overflow(GF_BitStream *bs);
+
/*! @} */
#ifdef __cplusplus
diff --git a/include/gpac/internal/media_dev.h b/include/gpac/internal/media_dev.h
index c1e20b011..c2c2833db 100644
--- a/include/gpac/internal/media_dev.h
+++ b/include/gpac/internal/media_dev.h
@@ -897,7 +897,7 @@ typedef struct
Bool mem_mode;
/*bitstream object for mem mode - this bitstream is NOT destroyed by gf_av1_reset_state(state, GF_TRUE) */
GF_BitStream *bs;
- Bool bs_overread, unframed;
+ Bool unframed;
u8 *frame_obus;
u32 frame_obus_alloc;
diff --git a/src/filters/bs_agg.c b/src/filters/bs_agg.c
index 13edde450..e29077169 100644
--- a/src/filters/bs_agg.c
+++ b/src/filters/bs_agg.c
@@ -440,10 +440,12 @@ static GF_Err nalu_process(BSAggCtx *ctx, BSAggOut *pctx, u32 codec_type)
{
u32 size, pck_size, i, count, tot_size=0, nb_done=0;
u64 min_dts = GF_FILTER_NO_TS;
- u32 min_timescale;
+ u32 min_timescale, min_nal_size;
GF_Err process_error = GF_OK;
Bool has_svc_prefix = GF_FALSE;
+ min_nal_size = codec_type ? 2 : 1;
+
count = gf_list_count(pctx->ipids);
for (i=0; i<count; i++) {
u64 ts;
@@ -517,11 +519,21 @@ static GF_Err nalu_process(BSAggCtx *ctx, BSAggOut *pctx, u32 codec_type)
e = GF_NON_COMPLIANT_BITSTREAM;
break;
}
+ if (nal_size < min_nal_size) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[BSAgg] Invalid NAL size %d but mn size %d\n", nal_size, min_nal_size));
+ e = GF_NON_COMPLIANT_BITSTREAM;
+ break;
+ }
//AVC
if (codec_type==0) {
nal_type = data[size] & 0x1F;
if ((nal_type == GF_AVC_NALU_SVC_PREFIX_NALU) || (nal_type==GF_AVC_NALU_SVC_SLICE)) {
+ if (nal_size < 4) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[BSAgg] Invalid NAL size %d but mn size 4\n", nal_size));
+ e = GF_NON_COMPLIANT_BITSTREAM;
+ break;
+ }
has_svc_prefix = GF_TRUE;
//quick parse svc nal header (right after 1-byte nal header)
//u32 prio_id = (data[size+1]) & 0x3F;
diff --git a/src/filters/bs_split.c b/src/filters/bs_split.c
index d8713ceeb..7dba22b84 100644
--- a/src/filters/bs_split.c
+++ b/src/filters/bs_split.c
@@ -1014,7 +1014,7 @@ static GF_Err none_split_packet(BSSplitCtx *ctx, BSSplitIn *pctx, GF_FilterPacke
static GF_Err nalu_split_packet(BSSplitCtx *ctx, BSSplitIn *pctx, GF_FilterPacket *pck, u32 codec_type)
{
- u32 size, pck_size;
+ u32 size, pck_size, min_nal_size;
GF_Err e;
u64 pck_ts;
Bool has_svc_prefix = GF_FALSE;
@@ -1034,6 +1034,7 @@ static GF_Err nalu_split_packet(BSSplitCtx *ctx, BSSplitIn *pctx, GF_FilterPacke
if (!pctx->first_ts_plus_one) {
pctx->first_ts_plus_one = pck_ts+1;
}
+ min_nal_size = codec_type ? 2 : 1;
size=0;
while (size<pck_size) {
@@ -1055,6 +1056,11 @@ static GF_Err nalu_split_packet(BSSplitCtx *ctx, BSSplitIn *pctx, GF_FilterPacke
e = GF_NON_COMPLIANT_BITSTREAM;
break;
}
+ if (nal_size < min_nal_size) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[BSSplit] Invalid NAL size %d but mn size %d\n", nal_size, min_nal_size));
+ e = GF_NON_COMPLIANT_BITSTREAM;
+ break;
+ }
//AVC
if (codec_type==0) {
diff --git a/src/filters/inspect.c b/src/filters/inspect.c
index 6512a6a66..6e106fd45 100644
--- a/src/filters/inspect.c
+++ b/src/filters/inspect.c
@@ -575,7 +575,7 @@ static void gf_inspect_dump_nalu_internal(FILE *dump, u8 *ptr, u32 ptr_size, Boo
if (hevc) {
#ifndef GPAC_DISABLE_HEVC
- if (ptr_size==1) {
+ if (ptr_size<=1) {
gf_fprintf(dump, "error=\"invalid nal size 1\"/>\n");
return;
}
@@ -863,6 +863,11 @@ static void gf_inspect_dump_nalu_internal(FILE *dump, u8 *ptr, u32 ptr_size, Boo
if (vvc) {
u8 lid, tid;
+ if (ptr_size<=1) {
+ gf_fprintf(dump, "error=\"invalid nal size 1\"/>\n");
+ return;
+ }
+
if (full_bs_dump) {
vvc->parse_mode = 2;
if (pctx) {
@@ -1015,6 +1020,10 @@ static void gf_inspect_dump_nalu_internal(FILE *dump, u8 *ptr, u32 ptr_size, Boo
}
//avc
+ if (!ptr_size) {
+ gf_fprintf(dump, "error=\"invalid nal size 1\"/>\n");
+ return;
+ }
type = ptr[0] & 0x1F;
nal_ref_idc = ptr[0] & 0x60;
nal_ref_idc>>=5;
diff --git a/src/filters/reframe_nalu.c b/src/filters/reframe_nalu.c
index 5354c19a0..f5e050f72 100644
--- a/src/filters/reframe_nalu.c
+++ b/src/filters/reframe_nalu.c
@@ -2159,6 +2159,8 @@ static s32 naludmx_parse_nal_hevc(GF_NALUDmxCtx *ctx, char *data, u32 size, Bool
u8 nal_unit_type, temporal_id, layer_id;
*skip_nal = GF_FALSE;
+ if (size<2) return -1;
+
gf_bs_reassign_buffer(ctx->bs_r, data, size);
res = gf_hevc_parse_nalu_bs(ctx->bs_r, ctx->hevc_state, &nal_unit_type, &temporal_id, &layer_id);
ctx->nb_nalus++;
@@ -2333,6 +2335,7 @@ static s32 naludmx_parse_nal_vvc(GF_NALUDmxCtx *ctx, char *data, u32 size, Bool
u8 nal_unit_type, temporal_id, layer_id;
*skip_nal = GF_FALSE;
+ if (size<2) return -1;
gf_bs_reassign_buffer(ctx->bs_r, data, size);
res = gf_vvc_parse_nalu_bs(ctx->bs_r, ctx->vvc_state, &nal_unit_type, &temporal_id, &layer_id);
ctx->nb_nalus++;
@@ -2510,6 +2513,7 @@ static s32 naludmx_parse_nal_avc(GF_NALUDmxCtx *ctx, char *data, u32 size, u32 n
s32 ps_idx = 0;
s32 res = 0;
+ if (!size) return -1;
gf_bs_reassign_buffer(ctx->bs_r, data, size);
*skip_nal = GF_FALSE;
res = gf_avc_parse_nalu(ctx->bs_r, ctx->avc_state);
diff --git a/src/isomedia/avc_ext.c b/src/isomedia/avc_ext.c
index bfe6ee7c0..da6b06317 100644
--- a/src/isomedia/avc_ext.c
+++ b/src/isomedia/avc_ext.c
@@ -2746,6 +2746,7 @@ GF_Err avcc_box_read(GF_Box *s, GF_BitStream *bs)
else
is_avcc = GF_FALSE;
+ //we don't use gf_odf_avc_cfg_read to deal with missing rext profile signaling on many files
ptr->config->configurationVersion = gf_bs_read_u8(bs);
ptr->config->AVCProfileIndication = gf_bs_read_u8(bs);
ptr->config->profile_compatibility = gf_bs_read_u8(bs);
@@ -2820,7 +2821,7 @@ GF_Err avcc_box_read(GF_Box *s, GF_BitStream *bs)
}
}
#endif
- GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("AVCC: invalid syntax for REXT profile, patching.\n"));
+ GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[isom/avcc] Missing REXT profile signaling, patching.\n"));
return GF_OK;
}
ISOM_DECREASE_SIZE(ptr, 4)
diff --git a/src/media_tools/av_parsers.c b/src/media_tools/av_parsers.c
index e66b1a2e0..0daae2752 100644
--- a/src/media_tools/av_parsers.c
+++ b/src/media_tools/av_parsers.c
@@ -1921,6 +1921,8 @@ GF_Err gf_vp9_parse_superframe(GF_BitStream *bs, u64 ivf_frame_size, u32 *num_fr
e = gf_bs_seek(bs, pos + ivf_frame_size - 1);
if (e) return e;
+ gf_bs_mark_overflow(bs, GF_TRUE);
+
byte = gf_bs_read_u8(bs);
if ((byte & 0xe0) != 0xc0)
goto exit; /*no superframe*/
@@ -1943,6 +1945,9 @@ GF_Err gf_vp9_parse_superframe(GF_BitStream *bs, u64 ivf_frame_size, u32 *num_fr
exit:
gf_bs_seek(bs, pos);
+
+ if (gf_bs_is_overflow(bs)) e = GF_NON_COMPLIANT_BITSTREAM;
+
return e;
}
@@ -2690,7 +2695,7 @@ GF_Err aom_av1_parse_temporal_unit_from_annexb(GF_BitStream *bs, AV1State *state
u64 tusize, sz;
if (!bs || !state) return GF_BAD_PARAM;
- state->bs_overread = GF_FALSE;
+ gf_bs_mark_overflow(bs, GF_TRUE);
tusize = sz = gf_av1_leb128_read(bs, NULL);
tupos = gf_bs_get_position(bs);
if (!sz) {
@@ -2703,7 +2708,7 @@ GF_Err aom_av1_parse_temporal_unit_from_annexb(GF_BitStream *bs, AV1State *state
u8 Leb128Bytes = 0;
u64 frame_unit_size = gf_av1_leb128_read(bs, &Leb128Bytes);
- if (state->bs_overread) {
+ if (gf_bs_is_overflow(bs)) {
return GF_BUFFER_TOO_SMALL;
}
if (sz < Leb128Bytes + frame_unit_size) {
@@ -2716,7 +2721,7 @@ GF_Err aom_av1_parse_temporal_unit_from_annexb(GF_BitStream *bs, AV1State *state
while (frame_unit_size > 0) {
u64 pos, obu_size = gf_av1_leb128_read(bs, &Leb128Bytes);
- if (state->bs_overread) {
+ if (gf_bs_is_overflow(bs)) {
return GF_BUFFER_TOO_SMALL;
}
if (frame_unit_size < Leb128Bytes + obu_size) {
@@ -4120,12 +4125,6 @@ static GF_Err av1_parse_frame(GF_BitStream *bs, AV1State *state, u64 obu_start,
return av1_parse_tile_group(bs, state, obu_start, obu_size);
}
-static void on_aom_av1_eos(void *_state)
-{
- AV1State *state = (AV1State *)_state;
- state->bs_overread = GF_TRUE;
-}
-
static void av1_parse_obu_metadata(AV1State *state, GF_BitStream *bs)
{
u32 metadata_type = (u32)gf_av1_leb128_read(bs, NULL);
@@ -4156,13 +4155,13 @@ GF_Err gf_av1_parse_obu(GF_BitStream *bs, ObuType *obu_type, u64 *obu_size, u32
if (!bs || !obu_type || !state)
return GF_BAD_PARAM;
- state->bs_overread = GF_FALSE;
- gf_bs_set_eos_callback(bs, on_aom_av1_eos, state);
+ gf_bs_mark_overflow(bs, GF_TRUE);
state->obu_extension_flag = state->obu_has_size_field = 0;
state->temporal_id = state->spatial_id = 0;
state->frame_state.uncompressed_header_bytes = 0;
e = gf_av1_parse_obu_header(bs, obu_type, &state->obu_extension_flag, &state->obu_has_size_field, &state->temporal_id, &state->spatial_id);
+ if (gf_bs_is_overflow(bs)) e = GF_NON_COMPLIANT_BITSTREAM;
if (e)
return e;
@@ -4180,7 +4179,7 @@ GF_Err gf_av1_parse_obu(GF_BitStream *bs, ObuType *obu_type, u64 *obu_size, u32
}
}
hdr_size = (u32)(gf_bs_get_position(bs) - pos);
- if ((gf_bs_available(bs) < *obu_size) || state->bs_overread) {
+ if (gf_bs_is_overflow(bs) || (gf_bs_available(bs) < *obu_size) ) {
gf_bs_seek(bs, pos);
return GF_BUFFER_TOO_SMALL;
}
@@ -4210,7 +4209,7 @@ GF_Err gf_av1_parse_obu(GF_BitStream *bs, ObuType *obu_type, u64 *obu_size, u32
switch (*obu_type) {
case OBU_SEQUENCE_HEADER:
av1_parse_sequence_header_obu(bs, state);
- if (gf_bs_get_position(bs) > pos + *obu_size) {
+ if (gf_bs_is_overflow(bs) || (gf_bs_get_position(bs) > pos + *obu_size)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[AV1] Sequence header parsing consumed too many bytes !\n"));
e = GF_NON_COMPLIANT_BITSTREAM;
}
@@ -4220,13 +4219,14 @@ GF_Err gf_av1_parse_obu(GF_BitStream *bs, ObuType *obu_type, u64 *obu_size, u32
case OBU_METADATA:
av1_parse_obu_metadata(state, bs);
gf_bs_seek(bs, pos + *obu_size);
+ if (gf_bs_is_overflow(bs)) e = GF_NON_COMPLIANT_BITSTREAM;
break;
case OBU_FRAME_HEADER:
case OBU_REDUNDANT_FRAME_HEADER:
if (state->config) {
av1_parse_frame_header(bs, state);
- if (gf_bs_get_position(bs) > pos + *obu_size) {
+ if (gf_bs_is_overflow(bs) || (gf_bs_get_position(bs) > pos + *obu_size)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[AV1] Frame header parsing consumed too many bytes !\n"));
e = GF_NON_COMPLIANT_BITSTREAM;
}
@@ -4235,7 +4235,7 @@ GF_Err gf_av1_parse_obu(GF_BitStream *bs, ObuType *obu_type, u64 *obu_size, u32
break;
case OBU_FRAME:
e = av1_parse_frame(bs, state, pos, *obu_size);
- if (gf_bs_get_position(bs) != pos + *obu_size) {
+ if (gf_bs_is_overflow(bs) || (gf_bs_get_position(bs) != pos + *obu_size)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[AV1] Frame parsing did not consume the right number of bytes !\n"));
e = GF_NON_COMPLIANT_BITSTREAM;
}
@@ -4244,7 +4244,7 @@ GF_Err gf_av1_parse_obu(GF_BitStream *bs, ObuType *obu_type, u64 *obu_size, u32
case OBU_TILE_GROUP:
if (state->config) {
e = av1_parse_tile_group(bs, state, pos, *obu_size);
- if (gf_bs_get_position(bs) != pos + *obu_size) {
+ if (gf_bs_is_overflow(bs) || (gf_bs_get_position(bs) != pos + *obu_size)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[AV1] Tile group parsing did not consume the right number of bytes !\n"));
e = GF_NON_COMPLIANT_BITSTREAM;
}
@@ -4733,12 +4733,15 @@ u32 gf_bs_read_ue_log_idx3(GF_BitStream *bs, const char *fname, s32 idx1, s32 id
}
if (nb_lead>=32) {
- //gf_bs_read_int keeps returning 0 on EOS, so if no more bits available, rbsp was truncated otherwise code is broken in rbsp)
- //we only test once nb_lead>=32 to avoid testing at each bit read
- if (!gf_bs_available(bs)) {
- GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[Core] exp-golomb read failed, not enough bits in bitstream !\n"));
- } else {
- GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[Core] corrupted exp-golomb code, %d leading zeros, max 31 allowed !\n", nb_lead));
+ if (gf_bs_is_overflow(bs)<2) {
+ //gf_bs_read_int keeps returning 0 on EOS, so if no more bits available, rbsp was truncated otherwise code is broken in rbsp)
+ //we only test once nb_lead>=32 to avoid testing at each bit read
+ if (!gf_bs_available(bs)) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[Core] exp-golomb read failed, not enough bits in bitstream !\n"));
+ } else {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[Core] corrupted exp-golomb code, %d leading zeros, max 31 allowed !\n", nb_lead));
+ }
+ gf_bs_mark_overflow(bs, GF_FALSE);
}
return 0;
}
@@ -6095,6 +6098,8 @@ s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)
AVCSliceInfo n_state;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
+ if (!gf_bs_available(bs)) return -1;
+ gf_bs_mark_overflow(bs, GF_TRUE);
nal_hdr = gf_bs_read_u8(bs);
@@ -6114,6 +6119,8 @@ s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)
case GF_AVC_NALU_SVC_SLICE:
SVC_ReadNal_header_extension(bs, &n_state.svc_nalhdr);
+ if (gf_bs_is_overflow(bs)) return -1;
+
// slice buffer - read the info and compare.
/*ret = */svc_parse_slice(bs, avc, &n_state);
if (avc->s_info.nal_ref_idc) {
@@ -6131,6 +6138,7 @@ s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)
case GF_AVC_NALU_SVC_PREFIX_NALU:
SVC_ReadNal_header_extension(bs, &avc->s_info.svc_nalhdr);
+ if (gf_bs_is_overflow(bs)) return -1;
return 0;
case GF_AVC_NALU_IDR_SLICE:
@@ -6141,6 +6149,7 @@ s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)
slice = 1;
/* slice buffer - read the info and compare.*/
ret = avc_parse_slice(bs, avc, idr_flag, &n_state);
+ if (gf_bs_is_overflow(bs)) ret = -1;
if (ret < 0) return ret;
ret = 0;
if (
@@ -6202,19 +6211,23 @@ s32 gf_avc_parse_nalu(GF_BitStream *bs, AVCState *avc)
break;
case GF_AVC_NALU_SEQ_PARAM:
avc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 0, NULL, nal_hdr);
+ if (gf_bs_is_overflow(bs)) return -1;
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_PIC_PARAM:
avc->last_ps_idx = gf_avc_read_pps_bs_internal(bs, avc, nal_hdr);
+ if (gf_bs_is_overflow(bs)) return -1;
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_SVC_SUBSEQ_PARAM:
avc->last_ps_idx = gf_avc_read_sps_bs_internal(bs, avc, 1, NULL, nal_hdr);
+ if (gf_bs_is_overflow(bs)) return -1;
if (avc->last_ps_idx < 0) return -1;
return 0;
case GF_AVC_NALU_SEQ_PARAM_EXT:
avc->last_ps_idx = (s32) gf_bs_read_ue(bs);
+ if (gf_bs_is_overflow(bs)) return -1;
if (avc->last_ps_idx < 0) return -1;
return 0;
@@ -8562,6 +8575,9 @@ s32 gf_hevc_parse_nalu_bs(GF_BitStream *bs, HEVCState *hevc, u8 *nal_unit_type,
HEVCSliceInfo n_state;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
+ if (gf_bs_available(bs)<2) return -1;
+
+ gf_bs_mark_overflow(bs, GF_TRUE);
memcpy(&n_state, &hevc->s_info, sizeof(HEVCSliceInfo));
if (!hevc_parse_nal_header(bs, nal_unit_type, temporal_id, layer_id)) return -1;
@@ -8629,6 +8645,9 @@ s32 gf_hevc_parse_nalu_bs(GF_BitStream *bs, HEVCState *hevc, u8 *nal_unit_type,
break;
}
+ if (gf_bs_is_overflow(bs))
+ ret = -1;
+
/* save _prev values */
if ((ret>0) && hevc->s_info.sps) {
n_state.frame_num_offset_prev = hevc->s_info.frame_num_offset;
@@ -8651,6 +8670,8 @@ s32 gf_hevc_parse_nalu(u8 *data, u32 size, HEVCState *hevc, u8 *nal_unit_type, u
GF_BitStream *bs = NULL;
s32 ret = -1;
+ if (size<2) return -1;
+
if (!hevc) {
if (nal_unit_type) (*nal_unit_type) = (data[0] & 0x7E) >> 1;
if (layer_id) {
@@ -11236,6 +11257,8 @@ s32 gf_vvc_parse_nalu_bs(GF_BitStream *bs, VVCState *vvc, u8 *nal_unit_type, u8
VVCSliceInfo n_state;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
+ if (gf_bs_available(bs)<2) return -1;
+ gf_bs_mark_overflow(bs, GF_TRUE);
memcpy(&n_state, &vvc->s_info, sizeof(VVCSliceInfo));
if (!vvc_parse_nal_header(bs, nal_unit_type, temporal_id, layer_id)) return -1;
@@ -11322,6 +11345,7 @@ s32 gf_vvc_parse_nalu_bs(GF_BitStream *bs, VVCState *vvc, u8 *nal_unit_type, u8
ret = 0;
break;
}
+ if (gf_bs_is_overflow(bs)) ret = -1;
/* save current POC lsb/msb to prev values */
if ((ret>0) && vvc->s_info.sps) {
@@ -11344,6 +11368,8 @@ s32 gf_vvc_parse_nalu(u8 *data, u32 size, VVCState *vvc, u8 *nal_unit_type, u8 *
GF_BitStream *bs = NULL;
s32 ret;
+ if (size<2) return -1;
+
if (!vvc) {
if (nal_unit_type) (*nal_unit_type) = data[1] >> 3;
if (layer_id) (*layer_id) = data[0] & 0x3f;
diff --git a/src/odf/descriptors.c b/src/odf/descriptors.c
index 8b4bf1817..0c2143c48 100644
--- a/src/odf/descriptors.c
+++ b/src/odf/descriptors.c
@@ -2,7 +2,7 @@
* GPAC - Multimedia Framework C SDK
*
* Authors: Jean Le Feuvre
- * Copyright (c) Telecom ParisTech 2000-2012
+ * Copyright (c) Telecom ParisTech 2000-2022
* All rights reserved
*
* This file is part of GPAC / MPEG-4 ObjectDescriptor sub-project
@@ -601,17 +601,47 @@ GF_AVCConfig *gf_odf_avc_cfg_read(u8 *dsi, u32 dsi_size)
gf_bs_read_int(bs, 3);
count = gf_bs_read_int(bs, 5);
for (i=0; i<count; i++) {
- GF_NALUFFParam *sl = (GF_NALUFFParam *)gf_malloc(sizeof(GF_NALUFFParam));
- sl->size = gf_bs_read_int(bs, 16);
+ GF_NALUFFParam *sl;
+ u32 size = gf_bs_read_int(bs, 16);
+ if ((size>gf_bs_available(bs)) || (size<2)) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[AVC] Wrong param set size %d\n", size));
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
+ GF_SAFEALLOC(sl, GF_NALUFFParam );
+ if (!sl) {
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
+ sl->size = size;
sl->data = (char*)gf_malloc(sizeof(char)*sl->size);
+ if (!sl->data) {
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
gf_bs_read_data(bs, sl->data, sl->size);
gf_list_add(avcc->sequenceParameterSets, sl);
}
count = gf_bs_read_int(bs, 8);
for (i=0; i<count; i++) {
- GF_NALUFFParam *sl = (GF_NALUFFParam *)gf_malloc(sizeof(GF_NALUFFParam));
- sl->size = gf_bs_read_int(bs, 16);
+ GF_NALUFFParam *sl;
+ u32 size = gf_bs_read_int(bs, 16);
+ if ((size>gf_bs_available(bs)) || (size<2)) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[AVC] Wrong param set size %d\n", size));
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
+ GF_SAFEALLOC(sl, GF_NALUFFParam );
+ if (!sl) {
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
+ sl->size = size;
sl->data = (char*)gf_malloc(sizeof(char)*sl->size);
+ if (!sl->data) {
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
gf_bs_read_data(bs, sl->data, sl->size);
gf_list_add(avcc->pictureParameterSets, sl);
}
@@ -627,9 +657,24 @@ GF_AVCConfig *gf_odf_avc_cfg_read(u8 *dsi, u32 dsi_size)
if (count) {
avcc->sequenceParameterSetExtensions = gf_list_new();
for (i=0; i<count; i++) {
- GF_NALUFFParam *sl = (GF_NALUFFParam *)gf_malloc(sizeof(GF_NALUFFParam));
- sl->size = gf_bs_read_u16(bs);
- sl->data = (char *)gf_malloc(sizeof(char) * sl->size);
+ GF_NALUFFParam *sl;
+ u32 size = gf_bs_read_int(bs, 16);
+ if ((size>gf_bs_available(bs)) || (size<2)) {
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[AVC] Wrong param set size %d\n", size));
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
+ GF_SAFEALLOC(sl, GF_NALUFFParam );
+ if (!sl) {
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
+ sl->size = size;
+ sl->data = (char*)gf_malloc(sizeof(char)*sl->size);
+ if (!sl->data) {
+ gf_odf_avc_cfg_del(avcc);
+ return NULL;
+ }
gf_bs_read_data(bs, sl->data, sl->size);
gf_list_add(avcc->sequenceParameterSetExtensions, sl);
}
@@ -1050,7 +1095,7 @@ GF_HEVCConfig *gf_odf_hevc_cfg_read_bs(GF_BitStream *bs, Bool is_lhvc)
for (j=0; j<nalucount; j++) {
GF_NALUFFParam *sl;
u32 size = gf_bs_read_int(bs, 16);
- if (size>gf_bs_available(bs)) {
+ if ((size>gf_bs_available(bs)) || (size<2)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[HEVC] Wrong param set size %d\n", size));
gf_odf_hevc_cfg_del(cfg);
return NULL;
@@ -1330,7 +1375,7 @@ GF_VVCConfig *gf_odf_vvc_cfg_read_bs(GF_BitStream *bs)
for (j=0; j<nalucount; j++) {
GF_NALUFFParam *sl;
u32 size = gf_bs_read_int(bs, 16);
- if (size>gf_bs_available(bs)) {
+ if ((size>gf_bs_available(bs)) || (size<2)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[VVC] Wrong param set size %d\n", size));
gf_odf_vvc_cfg_del(cfg);
return NULL;
diff --git a/src/utils/bitstream.c b/src/utils/bitstream.c
index dd235db17..6ea644ca1 100644
--- a/src/utils/bitstream.c
+++ b/src/utils/bitstream.c
@@ -77,6 +77,7 @@ struct __tag_bitstream
void *log_udta;
u32 total_bits_read;
+ u32 overflow_state;
};
GF_Err gf_bs_reassign_buffer(GF_BitStream *bs, const u8 *buffer, u64 BufferSize)
@@ -355,6 +356,7 @@ static u8 BS_ReadByte(GF_BitStream *bs)
u8 res;
if (bs->position >= bs->size) {
if (bs->EndOfStream) bs->EndOfStream(bs->par);
+ if (!bs->overflow_state) bs->overflow_state = 1;
return 0;
}
res = bs->original[bs->position++];
@@ -404,6 +406,7 @@ static u8 BS_ReadByte(GF_BitStream *bs)
bs_eof:
if (bs->EndOfStream) {
bs->EndOfStream(bs->par);
+ if (!bs->overflow_state) bs->overflow_state = 1;
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[BS] Attempt to overread bitstream\n"));
}
@@ -613,6 +616,7 @@ u64 gf_bs_read_long_int(GF_BitStream *bs, u32 nBits)
if (gf_bs_available(bs) * 8 < nBits-8) {
if (bs->EndOfStream) bs->EndOfStream(bs->par);
bs->position = bs->size;
+ if (!bs->overflow_state) bs->overflow_state = 1;
return 0;
}
GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Reading %d bits but max should be 64, skipping %d most significants bits\n", nBits, nBits-64));
@@ -1324,6 +1328,7 @@ static GF_Err BS_SeekIntern(GF_BitStream *bs, u64 offset)
GF_EXPORT
GF_Err gf_bs_seek(GF_BitStream *bs, u64 offset)
{
+ bs->overflow_state = 0;
if (bs->on_block_out) {
GF_Err e;
if (offset < bs->bytes_out) {
@@ -1706,3 +1711,11 @@ void gf_bs_log_idx(GF_BitStream *bs, u32 nBits, const char *fname, s64 val, s32
#endif
+void gf_bs_mark_overflow(GF_BitStream *bs, Bool reset)
+{
+ bs->overflow_state = reset ? 0 : 2;
+}
+u32 gf_bs_is_overflow(GF_BitStream *bs)
+{
+ return bs->overflow_state;
+}
|
3rdn4/gpac:a8bc2c8-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
a8bc2c8-heap_out_of_bound
|
/workspace/skyset/gpac/a8bc2c8-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/a8bc2c8-heap_out_of_bound/immutable/
|
diff --git a/src/scene_manager/swf_parse.c b/src/scene_manager/swf_parse.c
index f4b974aab..2afa80c3e 100644
--- a/src/scene_manager/swf_parse.c
+++ b/src/scene_manager/swf_parse.c
@@ -1426,7 +1426,7 @@ static GF_Err swf_def_font(SWFReader *read, u32 revision)
count = swf_get_16(read);
ft->nbGlyphs = count / 2;
offset_table = (u32*)gf_malloc(sizeof(u32) * ft->nbGlyphs);
- offset_table[0] = 0;
+ if (ft->nbGlyphs) offset_table[0] = 0;
for (i=1; i<ft->nbGlyphs; i++) offset_table[i] = swf_get_16(read);
for (i=0; i<ft->nbGlyphs; i++) {
|
3rdn4/gpac:b1042c3-null_pointer_deref
|
/workspace/skyset/
|
gpac
|
b1042c3-null_pointer_deref
|
/workspace/skyset/gpac/b1042c3-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/gpac/b1042c3-null_pointer_deref/immutable/
|
diff --git a/src/filters/dasher.c b/src/filters/dasher.c
index 2619d2291..bc768804f 100644
--- a/src/filters/dasher.c
+++ b/src/filters/dasher.c
@@ -8387,6 +8387,9 @@ static GF_Err dasher_process(GF_Filter *filter)
u32 num_ready=0, num_blocked=0;
for (i=0; i<count; i++) {
GF_DashStream *ds = gf_list_get(ctx->current_period->streams, i);
+ if (ctx->force_period_switch) {
+ break;
+ }
GF_FilterPacket *pck = gf_filter_pid_get_packet(ds->ipid);
if (!pck) continue;
u64 ts = gf_filter_pck_get_cts(pck);
@@ -8406,6 +8409,9 @@ static GF_Err dasher_process(GF_Filter *filter)
}
ctx->min_cts_period.num = min_ts;
ctx->min_cts_period.den = min_timescale;
+
+ if (ctx->force_period_switch)
+ count = gf_list_count(ctx->current_period->streams);
}
nb_init = has_init = nb_reg_done = 0;
diff --git a/src/media_tools/avilib.c b/src/media_tools/avilib.c
index 27cd81133..be93bc3a7 100644
--- a/src/media_tools/avilib.c
+++ b/src/media_tools/avilib.c
@@ -1948,8 +1948,11 @@ int avi_parse_input_file(avi_t *AVI, int getIndex)
header_offset = gf_ftell(AVI->fdes);
- if( avi_read(AVI->fdes,(char *)hdrl_data, (u32) n) != n ) ERR_EXIT(AVI_ERR_READ)
+ if( avi_read(AVI->fdes,(char *)hdrl_data, (u32) n) != n ) {
+ if (hdrl_data) gf_free(hdrl_data);
+ ERR_EXIT(AVI_ERR_READ)
}
+ }
else if(strnicmp(data,"movi",4) == 0)
{
AVI->movi_start = gf_ftell(AVI->fdes);
@@ -1964,19 +1967,24 @@ int avi_parse_input_file(avi_t *AVI, int getIndex)
AVI->n_idx = AVI->max_idx = (u32) (n/16);
AVI->idx = (unsigned char((*)[16]) ) gf_malloc((u32)n);
- if(AVI->idx==0) ERR_EXIT(AVI_ERR_NO_MEM)
- if(avi_read(AVI->fdes, (char *) AVI->idx, (u32) n) != n ) {
- gf_free( AVI->idx);
- AVI->idx=NULL;
- AVI->n_idx = 0;
- }
+ if(AVI->idx==0) {
+ if (hdrl_data) gf_free(hdrl_data);
+ ERR_EXIT(AVI_ERR_NO_MEM)
+ }
+ if(avi_read(AVI->fdes, (char *) AVI->idx, (u32) n) != n ) {
+ gf_free( AVI->idx);
+ AVI->idx=NULL;
+ AVI->n_idx = 0;
+ if (hdrl_data) gf_free(hdrl_data);
+ ERR_EXIT(AVI_ERR_READ)
+ }
}
else
gf_fseek(AVI->fdes,n,SEEK_CUR);
}
- if(!hdrl_data ) ERR_EXIT(AVI_ERR_NO_HDRL)
- if(!AVI->movi_start) ERR_EXIT(AVI_ERR_NO_MOVI)
+ if(!hdrl_data) ERR_EXIT(AVI_ERR_NO_HDRL)
+ if(!AVI->movi_start) ERR_EXIT(AVI_ERR_NO_MOVI)
/* Interpret the header list */
diff --git a/src/media_tools/mpeg2_ps.c b/src/media_tools/mpeg2_ps.c
index 8e33e48d4..0af7a31f3 100644
--- a/src/media_tools/mpeg2_ps.c
+++ b/src/media_tools/mpeg2_ps.c
@@ -996,6 +996,7 @@ static void get_info_from_frame (mpeg2ps_stream_t *sptr,
&sptr->par) < 0) {
sptr->m_stream_id = 0;
sptr->m_fd = FDNULL;
+ return;
}
sptr->ticks_per_frame = (u64)(90000.0 / sptr->frame_rate);
return;
@@ -1202,7 +1203,7 @@ static void get_info_for_all_streams (mpeg2ps_t *ps)
}
get_info_from_frame(sptr, buffer, buflen);
// here - if (sptr->first_pes_has_dts == 0) should be processed
- if (sptr->first_pes_has_dts == 0) {
+ if ((sptr->first_pes_has_dts == 0) && sptr->m_fd) {
u32 frames_from_beg = 0;
Bool have_frame;
do {
|
3rdn4/gpac:b6b6360-null_pointer_deref
|
/workspace/skyset/
|
gpac
|
b6b6360-null_pointer_deref
|
/workspace/skyset/gpac/b6b6360-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/gpac/b6b6360-null_pointer_deref/immutable/
|
diff --git a/applications/mp4box/filedump.c b/applications/mp4box/filedump.c
index 9eb463ab4..5974fca0d 100644
--- a/applications/mp4box/filedump.c
+++ b/applications/mp4box/filedump.c
@@ -3358,9 +3358,9 @@ void DumpTrackInfo(GF_ISOFile *file, GF_ISOTrackID trackID, Bool full_dump, Bool
fprintf(stderr, "\t3GPP DIMS stream - size %d x %d - Profile %d - Level %d\n", w, h, dims.profile, dims.level);
fprintf(stderr, "\tpathComponents: %d - useFullRequestHost: %s\n", dims.pathComponents, dims.fullRequestHost ? "yes" : "no");
fprintf(stderr, "\tstream type: %s - redundant: %s\n", dims.streamType ? "primary" : "secondary", (dims.containsRedundant==1) ? "main" : ((dims.containsRedundant==2) ? "redundant" : "main+redundant") );
- if (dims.textEncoding[0]) fprintf(stderr, "\ttext encoding %s\n", dims.textEncoding);
- if (dims.contentEncoding[0]) fprintf(stderr, "\tcontent encoding %s\n", dims.contentEncoding);
- if (dims.content_script_types) fprintf(stderr, "\tscript languages %s\n", dims.content_script_types);
+ if (dims.textEncoding && dims.textEncoding[0]) fprintf(stderr, "\ttext encoding %s\n", dims.textEncoding);
+ if (dims.contentEncoding && dims.contentEncoding[0]) fprintf(stderr, "\tcontent encoding %s\n", dims.contentEncoding);
+ if (dims.content_script_types && dims.content_script_types[0]) fprintf(stderr, "\tscript languages %s\n", dims.content_script_types);
} else if (mtype==GF_ISOM_MEDIA_HINT) {
u32 refTrack;
s32 refCount = gf_isom_get_reference_count(file, trackNum, GF_ISOM_REF_HINT);
|
3rdn4/gpac:bb9ee4c-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
bb9ee4c-heap_out_of_bound
|
/workspace/skyset/gpac/bb9ee4c-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/bb9ee4c-heap_out_of_bound/immutable/
|
diff --git a/src/isomedia/box_code_base.c b/src/isomedia/box_code_base.c
index 8154002a8..fa9b85242 100644
--- a/src/isomedia/box_code_base.c
+++ b/src/isomedia/box_code_base.c
@@ -242,9 +242,10 @@ GF_Err cprt_box_read(GF_Box *s,GF_BitStream *bs)
}
if (ptr->size) {
u32 bytesToRead = (u32) ptr->size;
- ptr->notice = (char*)gf_malloc(bytesToRead * sizeof(char));
+ ptr->notice = (char*)gf_malloc((bytesToRead+1) * sizeof(char));
if (ptr->notice == NULL) return GF_OUT_OF_MEM;
gf_bs_read_data(bs, ptr->notice, bytesToRead);
+ ptr->notice[bytesToRead] = 0;
}
return GF_OK;
}
|
3rdn4/gpac:be23476-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
be23476-heap_out_of_bound
|
/workspace/skyset/gpac/be23476-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/be23476-heap_out_of_bound/immutable/
|
diff --git a/src/filters/reframe_mp3.c b/src/filters/reframe_mp3.c
index e81dd174a..6ed5608b8 100644
--- a/src/filters/reframe_mp3.c
+++ b/src/filters/reframe_mp3.c
@@ -265,7 +265,7 @@ void id3dmx_flush(GF_Filter *filter, u8 *id3_buf, u32 id3_buf_size, GF_FilterPid
break;
}
- if (buf_alloc<=fsize) {
+ if (buf_alloc <= fsize+2) {
_buf = gf_realloc(_buf, fsize+3);
buf_alloc = fsize+3;
}
|
3rdn4/gpac:ca1b48f-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
ca1b48f-heap_out_of_bound
|
/workspace/skyset/gpac/ca1b48f-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/ca1b48f-heap_out_of_bound/immutable/
|
diff --git a/src/filters/reframe_mpgvid.c b/src/filters/reframe_mpgvid.c
index 576334f21..8e092f973 100644
--- a/src/filters/reframe_mpgvid.c
+++ b/src/filters/reframe_mpgvid.c
@@ -908,7 +908,7 @@ GF_Err mpgviddmx_process(GF_Filter *filter)
ctx->hdr_store_alloc = (u32) (ctx->hdr_store_size + pck_size - vosh_start);
ctx->hdr_store = gf_realloc(ctx->hdr_store, sizeof(char)*ctx->hdr_store_alloc);
}
- memcpy(ctx->hdr_store + ctx->hdr_store_size, data + vosh_start, (size_t) (pck_size - vosh_start) );
+ memmove(ctx->hdr_store + ctx->hdr_store_size, data + vosh_start, (size_t) (pck_size - vosh_start) );
ctx->hdr_store_size += pck_size - (u32) vosh_start;
}
gf_filter_pid_drop_packet(ctx->ipid);
@@ -956,7 +956,7 @@ GF_Err mpgviddmx_process(GF_Filter *filter)
ctx->hdr_store_alloc = (u32) (ctx->hdr_store_size + pck_size - (u32) vosh_start);
ctx->hdr_store = gf_realloc(ctx->hdr_store, sizeof(char)*ctx->hdr_store_alloc);
}
- memcpy(ctx->hdr_store + ctx->hdr_store_size, data + vosh_start, (size_t) (pck_size - vosh_start) );
+ memmove(ctx->hdr_store + ctx->hdr_store_size, data + vosh_start, (size_t) (pck_size - vosh_start) );
ctx->hdr_store_size += pck_size - (u32) vosh_start;
}
gf_filter_pid_drop_packet(ctx->ipid);
@@ -1410,5 +1410,3 @@ const GF_FilterRegister *rfmpgvid_register(GF_FilterSession *session)
return NULL;
}
#endif // #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_RFMPGVID)
-
-
|
3rdn4/gpac:cc95b16-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
cc95b16-heap_out_of_bound
|
/workspace/skyset/gpac/cc95b16-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/cc95b16-heap_out_of_bound/immutable/
|
diff --git a/src/media_tools/avilib.c b/src/media_tools/avilib.c
index 7cdca7d87..459ff8043 100644
--- a/src/media_tools/avilib.c
+++ b/src/media_tools/avilib.c
@@ -2077,11 +2077,13 @@ int avi_parse_input_file(avi_t *AVI, int getIndex)
alBITMAPINFOHEADER bih;
memcpy(&bih, hdrl_data + i, sizeof(alBITMAPINFOHEADER));
- AVI->bitmap_info_header = (alBITMAPINFOHEADER *)
- gf_malloc(str2ulong((unsigned char *)&bih.bi_size));
+ bih.bi_size = str2ulong((unsigned char *)&bih.bi_size);
+
+ if (i + bih.bi_size > hdrl_len) ERR_EXIT(AVI_ERR_READ)
+
+ AVI->bitmap_info_header = (alBITMAPINFOHEADER *) gf_malloc(bih.bi_size);
if (AVI->bitmap_info_header != NULL)
- memcpy(AVI->bitmap_info_header, hdrl_data + i,
- str2ulong((unsigned char *)&bih.bi_size));
+ memcpy(AVI->bitmap_info_header, hdrl_data + i, bih.bi_size);
AVI->width = str2ulong(hdrl_data+i+4);
AVI->height = str2ulong(hdrl_data+i+8);
|
3rdn4/gpac:d2de8b5-stack_out_of_bound
|
/workspace/skyset/
|
gpac
|
d2de8b5-stack_out_of_bound
|
/workspace/skyset/gpac/d2de8b5-stack_out_of_bound/report.txt
|
A stack out of bound found in /workspace/skyset/gpac/d2de8b5-stack_out_of_bound/immutable/
|
diff --git a/src/filters/load_text.c b/src/filters/load_text.c
index 637339822..877b285a8 100644
--- a/src/filters/load_text.c
+++ b/src/filters/load_text.c
@@ -377,6 +377,10 @@ char *gf_text_get_utf8_line(char *szLine, u32 lineSize, FILE *txt_in, s32 unicod
GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TXTIn] Line too long to convert to utf8 (len: %d)\n", len));
j = GF_ARRAY_LENGTH(szLineConv) -1 ;
}
+ if ( j >= lineSize ) {
+ GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TXTIn] UT8 converted line too long for buffer (len: %d, buffer: %d)\n", j, lineSize));
+ j = lineSize-1 ;
+ }
szLineConv[j] = 0;
strcpy(szLine, szLineConv);
return sOK;
|
3rdn4/gpac:de7f3a8-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
de7f3a8-heap_out_of_bound
|
/workspace/skyset/gpac/de7f3a8-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/de7f3a8-heap_out_of_bound/immutable/
|
diff --git a/src/media_tools/mpeg2_ps.c b/src/media_tools/mpeg2_ps.c
index 0af7a31f3..b0182f224 100644
--- a/src/media_tools/mpeg2_ps.c
+++ b/src/media_tools/mpeg2_ps.c
@@ -266,6 +266,8 @@ int MPEG12_ParseSeqHdr(unsigned char *pbuffer, u32 buflen, s32 *have_mpeg2, u32
u32 scode, ix;
s32 found = -1;
*have_mpeg2 = 0;
+ if (buflen<6) return found;
+
buflen -= 6;
bitrate_int = 0;
for (ix = 0; ix < buflen; ix++, pbuffer++) {
|
3rdn4/gpac:ebedc7a-use_after_free
|
/workspace/skyset/
|
gpac
|
ebedc7a-use_after_free
|
/workspace/skyset/gpac/ebedc7a-use_after_free/report.txt
|
A use after free found in /workspace/skyset/gpac/ebedc7a-use_after_free/immutable/
|
diff --git a/src/bifs/memory_decoder.c b/src/bifs/memory_decoder.c
index 540fe9ed2..74d635750 100644
--- a/src/bifs/memory_decoder.c
+++ b/src/bifs/memory_decoder.c
@@ -936,7 +936,12 @@ GF_Err gf_bifs_flush_command_list(GF_BifsDecoder *codec)
GF_Err e;
CommandBufferItem *cbi;
GF_SceneGraph *prev_root = codec->current_graph;
+ M_QuantizationParameter *prev_qp = codec->ActiveQP;
+ u32 prev_qp_count = gf_list_count(codec->QPs);
u32 NbPass = gf_list_count(codec->command_buffers);
+
+
+ codec->ActiveQP = NULL;
GF_List *nextPass = gf_list_new();
while (NbPass) {
while (gf_list_count(codec->command_buffers)) {
@@ -987,10 +992,17 @@ GF_Err gf_bifs_flush_command_list(GF_BifsDecoder *codec)
}
NbPass --;
if (NbPass > gf_list_count(codec->command_buffers)) NbPass = gf_list_count(codec->command_buffers);
+
+ //restore QP state
+ while (gf_list_count(codec->QPs) > prev_qp_count) {
+ gf_list_rem(codec->QPs, 0); //QPs are inserted at head of list
+ }
+ codec->ActiveQP = NULL;
codec->LastError = GF_OK;
}
gf_list_del(nextPass);
codec->current_graph = prev_root;
+ codec->ActiveQP = prev_qp;
return GF_OK;
}
|
3rdn4/gpac:fc9e290-heap_out_of_bound
|
/workspace/skyset/
|
gpac
|
fc9e290-heap_out_of_bound
|
/workspace/skyset/gpac/fc9e290-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/gpac/fc9e290-heap_out_of_bound/immutable/
|
diff --git a/src/filters/reframe_mpgvid.c b/src/filters/reframe_mpgvid.c
index 8e092f973..ecf251955 100644
--- a/src/filters/reframe_mpgvid.c
+++ b/src/filters/reframe_mpgvid.c
@@ -1081,6 +1081,11 @@ GF_Err mpgviddmx_process(GF_Filter *filter)
//needs adjustement
if (bytes_from_store) {
size += bytes_from_store + hdr_offset;
+ if (size > remain) {
+ e = GF_NON_COMPLIANT_BITSTREAM;
+ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[MPGVid] packet too large to process (size %llu remain %d)\n", size, remain ));
+ break;
+ }
}
if ((e == GF_EOS) && !ctx->input_is_au_end) {
|
3rdn4/h3:f581626-global_buffer_overflow
|
/workspace/skyset/
|
h3
|
f581626-global_buffer_overflow
|
/workspace/skyset/h3/f581626-global_buffer_overflow/report.txt
|
A global buffer overflow found in /workspace/skyset/h3/f581626-global_buffer_overflow/immutable/
|
From fce1c53844ca21dcc14f3acabeaf2e12d47e5568 Mon Sep 17 00:00:00 2001
From: Isaac Brodsky <[email protected]>
Date: Mon, 12 Sep 2022 16:55:26 -0700
Subject: [PATCH] Fix potential OOB read in localIjToCell (#684)
---
src/apps/testapps/testCellToLocalIj.c | 8 ++++++++
src/h3lib/lib/coordijk.c | 9 +++++----
src/h3lib/lib/localij.c | 6 +++---
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/apps/testapps/testCellToLocalIj.c b/src/apps/testapps/testCellToLocalIj.c
index fd64eb6b4..944d1eb13 100644
--- a/src/apps/testapps/testCellToLocalIj.c
+++ b/src/apps/testapps/testCellToLocalIj.c
@@ -272,4 +272,12 @@ SUITE(h3ToLocalIj) {
"Invalid mode fail for cellToLocalIj");
}
}
+
+ TEST(invalid_negativeIj) {
+ H3Index index = 0x200f202020202020;
+ CoordIJ ij = {.i = -14671840, .j = -2147483648};
+ H3Index out;
+ t_assert(H3_EXPORT(localIjToCell)(index, &ij, 0, &out) == E_FAILED,
+ "Negative I and J components fail");
+ }
}
diff --git a/src/h3lib/lib/coordijk.c b/src/h3lib/lib/coordijk.c
index 91771bdf8..b3533ed0d 100644
--- a/src/h3lib/lib/coordijk.c
+++ b/src/h3lib/lib/coordijk.c
@@ -245,11 +245,12 @@ void _ijkNormalize(CoordIJK *c) {
}
/**
- * Determines the H3 digit corresponding to a unit vector in ijk coordinates.
+ * Determines the H3 digit corresponding to a unit vector or the zero vector
+ * in ijk coordinates.
*
- * @param ijk The ijk coordinates; must be a unit vector.
- * @return The H3 digit (0-6) corresponding to the ijk unit vector, or
- * INVALID_DIGIT on failure.
+ * @param ijk The ijk coordinates; must be a unit vector or zero vector.
+ * @return The H3 digit (0-6) corresponding to the ijk unit vector, zero vector,
+ * or INVALID_DIGIT (7) on failure.
*/
Direction _unitIjkToDigit(const CoordIJK *ijk) {
CoordIJK c = *ijk;
diff --git a/src/h3lib/lib/localij.c b/src/h3lib/lib/localij.c
index 6e338c6d5..8b0730265 100644
--- a/src/h3lib/lib/localij.c
+++ b/src/h3lib/lib/localij.c
@@ -317,12 +317,12 @@ H3Error localIjkToCell(H3Index origin, const CoordIJK *ijk, H3Index *out) {
// check for res 0/base cell
if (res == 0) {
- if (ijk->i > 1 || ijk->j > 1 || ijk->k > 1) {
- // out of range input
+ const Direction dir = _unitIjkToDigit(ijk);
+ if (dir == INVALID_DIGIT) {
+ // out of range input - not a unit vector or zero vector
return E_FAILED;
}
- const Direction dir = _unitIjkToDigit(ijk);
const int newBaseCell = _getBaseCellNeighbor(originBaseCell, dir);
if (newBaseCell == INVALID_BASE_CELL) {
// Moving in an invalid direction off a pentagon.
|
3rdn4/hoextdown:933f9da-heap_buffer_overflow
|
/workspace/skyset/
|
hoextdown
|
933f9da-heap_buffer_overflow
|
/workspace/skyset/hoextdown/933f9da-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/hoextdown/933f9da-heap_buffer_overflow/immutable/
|
From 7c7dc6ac9adce5413ab54dcd604db95a9b935b05 Mon Sep 17 00:00:00 2001
From: Martin von Gagern <[email protected]>
Date: Mon, 29 Jun 2020 13:15:08 +0100
Subject: [PATCH] Avoid out-of-bounds read in code fence detection
---
src/document.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/document.c b/src/document.c
index fcd1696..a504c2e 100644
--- a/src/document.c
+++ b/src/document.c
@@ -1789,8 +1789,10 @@ is_codefence(uint8_t *data, size_t size, size_t *width, uint8_t *chr)
if (data[2] == ' ') { i++; } } }
/* looking at the hrule uint8_t */
+ if (i + 2 >= size)
+ return 0;
c = data[i];
- if (i + 2 >= size || !(c=='~' || c=='`'))
+ if (!(c=='~' || c=='`'))
return 0;
/* the fence must be that same character */
|
3rdn4/hostap:8112131-unknown_read
|
/workspace/skyset/
|
hostap
|
8112131-unknown_read
|
/workspace/skyset/hostap/8112131-unknown_read/report.txt
|
A unknown read found in /workspace/skyset/hostap/8112131-unknown_read/immutable/
|
commit 947272febe24a8f0ea828b5b2f35f13c3821901e
Author: Jouni Malinen <[email protected]>
Date: Mon Nov 9 11:43:12 2020 +0200
P2P: Fix copying of secondary device types for P2P group client
Parsing and copying of WPS secondary device types list was verifying
that the contents is not too long for the internal maximum in the case
of WPS messages, but similar validation was missing from the case of P2P
group information which encodes this information in a different
attribute. This could result in writing beyond the memory area assigned
for these entries and corrupting memory within an instance of struct
p2p_device. This could result in invalid operations and unexpected
behavior when trying to free pointers from that corrupted memory.
Credit to OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27269
Fixes: e57ae6e19edf ("P2P: Keep track of secondary device types for peers")
Signed-off-by: Jouni Malinen <[email protected]>
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 74b7b52ae..5cbfc217f 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -453,6 +453,8 @@ static void p2p_copy_client_info(struct p2p_device *dev,
dev->info.config_methods = cli->config_methods;
os_memcpy(dev->info.pri_dev_type, cli->pri_dev_type, 8);
dev->info.wps_sec_dev_type_list_len = 8 * cli->num_sec_dev_types;
+ if (dev->info.wps_sec_dev_type_list_len > WPS_SEC_DEV_TYPE_MAX_LEN)
+ dev->info.wps_sec_dev_type_list_len = WPS_SEC_DEV_TYPE_MAX_LEN;
os_memcpy(dev->info.wps_sec_dev_type_list, cli->sec_dev_types,
dev->info.wps_sec_dev_type_list_len);
}
|
3rdn4/htslib:dd6f0b7-unknown_read
|
/workspace/skyset/
|
htslib
|
dd6f0b7-unknown_read
|
/workspace/skyset/htslib/dd6f0b7-unknown_read/report.txt
|
A unknown read found in /workspace/skyset/htslib/dd6f0b7-unknown_read/immutable/
|
From 92ea05adb2478c64be571aff6fe00130fd29c252 Mon Sep 17 00:00:00 2001
From: James Bonfield <[email protected]>
Date: Mon, 14 Oct 2019 11:23:28 +0100
Subject: [PATCH] Bug fix a read-beyond-buffer bug in VCF code.
The VCF write code only checked the upper range of z->key, not
noticing it's signed.
Credit to OSS-Fuzz
Fixes oss-fuzz id 18196
---
vcf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/vcf.c b/vcf.c
index c2228312f..e02fd24d5 100644
--- a/vcf.c
+++ b/vcf.c
@@ -2830,8 +2830,9 @@ int vcf_format(const bcf_hdr_t *h, const bcf1_t *v, kstring_t *s)
if ( !z->vptr ) continue;
if ( !first ) kputc(';', s);
first = 0;
- if (z->key >= h->n[BCF_DT_ID]) {
- hts_log_error("Invalid BCF, the INFO index is too large");
+ if (z->key < 0 || z->key >= h->n[BCF_DT_ID]) {
+ hts_log_error("Invalid BCF, the INFO index %d is %s",
+ z->key, z->key < 0 ? "negative" : "too large");
errno = EINVAL;
return -1;
}
|
3rdn4/hunspell:1c1f34f-heap_buffer_overflow
|
/workspace/skyset/
|
hunspell
|
1c1f34f-heap_buffer_overflow
|
/workspace/skyset/hunspell/1c1f34f-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/hunspell/1c1f34f-heap_buffer_overflow/immutable/
|
From bf229433b9ba7131bd80b52b8c71399230e0dc12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Mon, 5 Dec 2022 09:14:46 +0000
Subject: [PATCH] ofz#54030 ensure sane bounds
---
src/hunspell/affixmgr.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index d6ffc3c10..e6d207833 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -2084,7 +2084,7 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
numsyllable, maxwordnum, wnum + 1, words, rwords, 0,
is_sug, info);
- if (rv && !checkcpdtable.empty() &&
+ if (rv && !checkcpdtable.empty() && i < word.size() &&
((scpd == 0 &&
cpdpat_check(word, i, rv_first, rv, affixed)) ||
(scpd != 0 &&
|
3rdn4/hunspell:473241e-heap_buffer_overflow
|
/workspace/skyset/
|
hunspell
|
473241e-heap_buffer_overflow
|
/workspace/skyset/hunspell/473241e-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/hunspell/473241e-heap_buffer_overflow/immutable/
|
From cbaaf7fd814793c204398519821b4ef8139a23b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Mon, 17 Oct 2022 20:11:08 +0100
Subject: [PATCH] ofz#52486 if we restore to oldi and orig str, surely len
needs to be reset
---
src/hunspell/affixmgr.cxx | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index 0e132ad90..c1d21fe3e 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -2161,6 +2161,9 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
i = soldi;
st.assign(word); // XXX add more optim.
soldi = 0;
+ len = oldlen;
+ cmin = oldcmin;
+ cmax = oldcmax;
} else
st[i] = ch;
|
3rdn4/hunspell:6291cac-heap_buffer_overflow_a
|
/workspace/skyset/
|
hunspell
|
6291cac-heap_buffer_overflow_a
|
/workspace/skyset/hunspell/6291cac-heap_buffer_overflow_a/report.txt
|
A heap buffer overflow a found in /workspace/skyset/hunspell/6291cac-heap_buffer_overflow_a/immutable/
|
From e7c38b0f85d65a6ad6af47753228f4b0df335c8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Fri, 16 Sep 2022 10:02:13 +0100
Subject: [PATCH] ofz#51430 use std::string::compare
---
src/hunspell/affixmgr.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index d692e3018..99a7005d4 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -2122,7 +2122,7 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
return NULL;
// check first part
- if (strncmp(rv->word, word.c_str() + i, rv->blen) == 0) {
+ if (word.compare(i, rv->blen, rv->word, rv->blen) == 0) {
char r = st[i + rv->blen];
st[i + rv->blen] = '\0';
|
3rdn4/hunspell:6291cac-heap_buffer_overflow_b
|
/workspace/skyset/
|
hunspell
|
6291cac-heap_buffer_overflow_b
|
/workspace/skyset/hunspell/6291cac-heap_buffer_overflow_b/report.txt
|
A heap buffer overflow b found in /workspace/skyset/hunspell/6291cac-heap_buffer_overflow_b/immutable/
|
From ef41c16af9a7fe0df27f421bd90120363c60dbb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Fri, 7 Oct 2022 09:11:34 +0100
Subject: [PATCH] ofz#52195 check bounds
it might be we wanted st here not word
---
src/hunspell/affixmgr.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index 17762b31a..57c8308a2 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -1879,7 +1879,7 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
if (striple) {
checkedstriple = 1;
i--; // check "fahrt" instead of "ahrt" in "Schiffahrt"
- } else if (i > 2 && word[i - 1] == word[i - 2])
+ } else if (i > 2 && i <= word.size() && word[i - 1] == word[i - 2])
striple = 1;
}
|
3rdn4/hunspell:6291cac-stack_buffer_overflow_a
|
/workspace/skyset/
|
hunspell
|
6291cac-stack_buffer_overflow_a
|
/workspace/skyset/hunspell/6291cac-stack_buffer_overflow_a/report.txt
|
A stack buffer overflow a found in /workspace/skyset/hunspell/6291cac-stack_buffer_overflow_a/immutable/
|
From e7c38b0f85d65a6ad6af47753228f4b0df335c8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Fri, 16 Sep 2022 10:02:13 +0100
Subject: [PATCH] ofz#51430 use std::string::compare
---
src/hunspell/affixmgr.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index d692e3018..99a7005d4 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -2122,7 +2122,7 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
return NULL;
// check first part
- if (strncmp(rv->word, word.c_str() + i, rv->blen) == 0) {
+ if (word.compare(i, rv->blen, rv->word, rv->blen) == 0) {
char r = st[i + rv->blen];
st[i + rv->blen] = '\0';
|
3rdn4/hunspell:6291cac-stack_buffer_overflow_b
|
/workspace/skyset/
|
hunspell
|
6291cac-stack_buffer_overflow_b
|
/workspace/skyset/hunspell/6291cac-stack_buffer_overflow_b/report.txt
|
A stack buffer overflow b found in /workspace/skyset/hunspell/6291cac-stack_buffer_overflow_b/immutable/
|
From 35c3cad4d70b222e7c1d73211a79a96ff7bf3651 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Sat, 17 Sep 2022 20:59:39 +0100
Subject: [PATCH] ofz#51498 abandon early on dubious pattern replacement
outcome
---
src/hunspell/affixmgr.cxx | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index 99a7005d4..ef3cde57a 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -1677,6 +1677,9 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
cmax = len - cpdmin + 1;
}
+ if (i > st.size())
+ return NULL;
+
ch = st[i];
st[i] = '\0';
|
3rdn4/hunspell:74b08bf-heap_buffer_overflow_a
|
/workspace/skyset/
|
hunspell
|
74b08bf-heap_buffer_overflow_a
|
/workspace/skyset/hunspell/74b08bf-heap_buffer_overflow_a/report.txt
|
A heap buffer overflow a found in /workspace/skyset/hunspell/74b08bf-heap_buffer_overflow_a/immutable/
|
From ebf0e2ce8d903815a6e8d828286394b6f8830860 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Thu, 8 Sep 2022 15:53:42 +0100
Subject: [PATCH] ofz#51124 negative array index with malformed .aff
---
src/hunspell/affixmgr.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index d6010b289..1c2b8b982 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -4820,7 +4820,7 @@ int AffixMgr::redundant_condition(char ft,
linenum);
return 0;
}
- } else {
+ } else if (j > 0) {
in = 0;
do {
j--;
|
3rdn4/hunspell:74b08bf-heap_buffer_overflow_b
|
/workspace/skyset/
|
hunspell
|
74b08bf-heap_buffer_overflow_b
|
/workspace/skyset/hunspell/74b08bf-heap_buffer_overflow_b/report.txt
|
A heap buffer overflow b found in /workspace/skyset/hunspell/74b08bf-heap_buffer_overflow_b/immutable/
|
From 7357713ba5d529f3ff70c654b703429fc9cb55a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Mon, 3 Oct 2022 21:02:13 +0100
Subject: [PATCH] ofz#51988 avoid going past start of invalid utf-8 sequence
---
src/hunspell/affixmgr.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index f32a456a9..0793b671b 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -1353,7 +1353,7 @@ int AffixMgr::cpdpat_check(const char* word,
int AffixMgr::cpdcase_check(const char* word, int pos) {
if (utf8) {
const char* p;
- for (p = word + pos - 1; (*p & 0xc0) == 0x80; p--)
+ for (p = word + pos - 1; p > word && (*p & 0xc0) == 0x80; p--)
;
std::string pair(p);
std::vector<w_char> pair_u;
|
3rdn4/hunspell:74b08bf-heap_double_free
|
/workspace/skyset/
|
hunspell
|
74b08bf-heap_double_free
|
/workspace/skyset/hunspell/74b08bf-heap_double_free/report.txt
|
A heap double free found in /workspace/skyset/hunspell/74b08bf-heap_double_free/immutable/
|
From 7d1c7d46c7a7fcd9987fc2691712b0696ab6646c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Fri, 16 Sep 2022 09:41:39 +0100
Subject: [PATCH] ofz#51432 double-free with bad .aff
---
src/hunspell/hashmgr.cxx | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/src/hunspell/hashmgr.cxx b/src/hunspell/hashmgr.cxx
index 3328e5301..75803f8c9 100644
--- a/src/hunspell/hashmgr.cxx
+++ b/src/hunspell/hashmgr.cxx
@@ -722,8 +722,17 @@ int HashMgr::decode_flags(unsigned short** result, const std::string& flags, Fil
len /= 2;
*result = new unsigned short[len];
for (int i = 0; i < len; i++) {
- (*result)[i] = ((unsigned short)((unsigned char)flags[i * 2]) << 8) +
- (unsigned char)flags[i * 2 + 1];
+ unsigned short flag = ((unsigned short)((unsigned char)flags[i * 2]) << 8) +
+ (unsigned char)flags[i * 2 + 1];
+
+ if (flag >= DEFAULTFLAGS) {
+ HUNSPELL_WARNING(stderr,
+ "error: line %d: flag id %d is too large (max: %d)\n",
+ af->getlinenum(), flag, DEFAULTFLAGS - 1);
+ flag = 0;
+ }
+
+ (*result)[i] = flag;
}
break;
}
@@ -741,10 +750,12 @@ int HashMgr::decode_flags(unsigned short** result, const std::string& flags, Fil
for (size_t p = 0; p < flags.size(); ++p) {
if (flags[p] == ',') {
int i = atoi(src);
- if (i >= DEFAULTFLAGS)
+ if (i >= DEFAULTFLAGS) {
HUNSPELL_WARNING(
stderr, "error: line %d: flag id %d is too large (max: %d)\n",
af->getlinenum(), i, DEFAULTFLAGS - 1);
+ i = 0;
+ }
*dest = (unsigned short)i;
if (*dest == 0)
HUNSPELL_WARNING(stderr, "error: line %d: 0 is wrong flag id\n",
@@ -754,10 +765,12 @@ int HashMgr::decode_flags(unsigned short** result, const std::string& flags, Fil
}
}
int i = atoi(src);
- if (i >= DEFAULTFLAGS)
+ if (i >= DEFAULTFLAGS) {
HUNSPELL_WARNING(stderr,
"error: line %d: flag id %d is too large (max: %d)\n",
af->getlinenum(), i, DEFAULTFLAGS - 1);
+ i = 0;
+ }
*dest = (unsigned short)i;
if (*dest == 0)
HUNSPELL_WARNING(stderr, "error: line %d: 0 is wrong flag id\n",
@@ -810,10 +823,12 @@ bool HashMgr::decode_flags(std::vector<unsigned short>& result, const std::strin
for (const char* p = src; *p; p++) {
if (*p == ',') {
int i = atoi(src);
- if (i >= DEFAULTFLAGS)
+ if (i >= DEFAULTFLAGS) {
HUNSPELL_WARNING(
stderr, "error: line %d: flag id %d is too large (max: %d)\n",
af->getlinenum(), i, DEFAULTFLAGS - 1);
+ i = 0;
+ }
result.push_back((unsigned short)i);
if (result.back() == 0)
HUNSPELL_WARNING(stderr, "error: line %d: 0 is wrong flag id\n",
@@ -822,10 +837,12 @@ bool HashMgr::decode_flags(std::vector<unsigned short>& result, const std::strin
}
}
int i = atoi(src);
- if (i >= DEFAULTFLAGS)
+ if (i >= DEFAULTFLAGS) {
HUNSPELL_WARNING(stderr,
"error: line %d: flag id %d is too large (max: %d)\n",
af->getlinenum(), i, DEFAULTFLAGS - 1);
+ i = 0;
+ }
result.push_back((unsigned short)i);
if (result.back() == 0)
HUNSPELL_WARNING(stderr, "error: line %d: 0 is wrong flag id\n",
@@ -860,9 +877,11 @@ unsigned short HashMgr::decode_flag(const std::string& f) const {
break;
case FLAG_NUM:
i = atoi(f.c_str());
- if (i >= DEFAULTFLAGS)
+ if (i >= DEFAULTFLAGS) {
HUNSPELL_WARNING(stderr, "error: flag id %d is too large (max: %d)\n",
i, DEFAULTFLAGS - 1);
+ i = 0;
+ }
s = (unsigned short)i;
break;
case FLAG_UNI: {
|
3rdn4/hunspell:82b9212-heap_use_after_free
|
/workspace/skyset/
|
hunspell
|
82b9212-heap_use_after_free
|
/workspace/skyset/hunspell/82b9212-heap_use_after_free/report.txt
|
A heap use after free found in /workspace/skyset/hunspell/82b9212-heap_use_after_free/immutable/
|
commit c6d900cfd5d10c428008dc40f804b9d9319cec87
Author: Caolán McNamara <[email protected]>
Date: Tue Mar 7 12:44:07 2023 +0000
ofz#56737 use int instead of short in free_flag
diff --git a/src/hunspell/hashmgr.cxx b/src/hunspell/hashmgr.cxx
index 1818da5..ca4a71a 100644
--- a/src/hunspell/hashmgr.cxx
+++ b/src/hunspell/hashmgr.cxx
@@ -106,7 +106,7 @@ HashMgr::HashMgr(const char* tpath, const char* apath, const char* key)
}
}
-void HashMgr::free_flag(unsigned short* astr, short alen) {
+void HashMgr::free_flag(unsigned short* astr, int alen) {
if (astr && (aliasf.empty() || TESTAFF(astr, ONLYUPCASEFLAG, alen)))
delete[] astr;
}
diff --git a/src/hunspell/hashmgr.hxx b/src/hunspell/hashmgr.hxx
index eb8c21f..fb465d2 100644
--- a/src/hunspell/hashmgr.hxx
+++ b/src/hunspell/hashmgr.hxx
@@ -152,7 +152,7 @@ class HashMgr {
bool parse_reptable(const std::string& line, FileMgr* af);
int remove_forbidden_flag(const std::string& word);
void free_table();
- void free_flag(unsigned short* astr, short alen);
+ void free_flag(unsigned short* astr, int alen);
};
#endif
|
3rdn4/hunspell:ddec95b-heap_buffer_overflow
|
/workspace/skyset/
|
hunspell
|
ddec95b-heap_buffer_overflow
|
/workspace/skyset/hunspell/ddec95b-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/hunspell/ddec95b-heap_buffer_overflow/immutable/
|
From ab3825969d2a78f9871242c9ce89fcd34a3ddafe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <[email protected]>
Date: Sat, 24 Jun 2023 21:01:01 +0100
Subject: [PATCH] ofz#60034 restore cmin/cmax before continue
---
src/hunspell/affixmgr.cxx | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/hunspell/affixmgr.cxx b/src/hunspell/affixmgr.cxx
index c193105af..a9e395eb7 100644
--- a/src/hunspell/affixmgr.cxx
+++ b/src/hunspell/affixmgr.cxx
@@ -1675,12 +1675,21 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
// compound words, overriding the effect of COMPOUNDPERMITFLAG
if ((rv) && compoundforbidflag &&
TESTAFF(rv->astr, compoundforbidflag, rv->alen) && !hu_mov_rule) {
- // given the while conditions that continue jumps to, this situation
- // never ends
- if (!scpd && !onlycpdrule && simplifiedcpd) {
+ bool would_continue = !onlycpdrule && simplifiedcpd;
+ if (!scpd && would_continue) {
+ // given the while conditions that continue jumps to, this situation
+ // never ends
HUNSPELL_WARNING(stderr, "break infinite loop\n");
break;
}
+
+ if (scpd > 0 && would_continue) {
+ // under these conditions we loop again, but the assumption above
+ // appears to be that cmin and cmax are the original values they
+ // had in the outside loop
+ cmin = oldcmin;
+ cmax = oldcmax;
+ }
continue;
}
|
3rdn4/irssi:afcb483-heap_use_after_free
|
/workspace/skyset/
|
irssi
|
afcb483-heap_use_after_free
|
/workspace/skyset/irssi/afcb483-heap_use_after_free/report.txt
|
A heap use after free found in /workspace/skyset/irssi/afcb483-heap_use_after_free/immutable/
|
From 3dbfac5699c6887b7149a0b1c805c4730f63d0f4 Mon Sep 17 00:00:00 2001
From: Ailin Nemui <[email protected]>
Date: Tue, 20 Apr 2021 09:11:06 +0200
Subject: [PATCH] fuzz test
---
.github/workflows/cifuzz.yml | 1 +
src/fe-fuzz/server.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml
index 9f956d5c1..a32e335d3 100644
--- a/.github/workflows/cifuzz.yml
+++ b/.github/workflows/cifuzz.yml
@@ -8,6 +8,7 @@ on:
- 'src/irc/**/*.c'
- 'src/fe-common/irc/**/*.c'
- 'src/lib-config/**/*.c'
+ - 'src/fe-fuzz/**/*.c'
- 'tests/**/*.c'
- '.github/workflows/cifuzz.yml'
jobs:
diff --git a/src/fe-fuzz/server.c b/src/fe-fuzz/server.c
index a2ffb9e9e..83ce7bfaa 100644
--- a/src/fe-fuzz/server.c
+++ b/src/fe-fuzz/server.c
@@ -186,9 +186,11 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
server_ref(server);
signal_emit("server incoming", 2, server, prefixedLine);
disconnected = server->disconnected;
+ /*
if (disconnected) {
- server_connect_unref(server->connrec);
+ server_connect_unref(server->connrec);
}
+ */
server_unref(server);
if (disconnected) {
/* reconnect */
|
3rdn4/irssi:b472570-heap_buffer_overflow_a
|
/workspace/skyset/
|
irssi
|
b472570-heap_buffer_overflow_a
|
/workspace/skyset/irssi/b472570-heap_buffer_overflow_a/report.txt
|
A heap buffer overflow a found in /workspace/skyset/irssi/b472570-heap_buffer_overflow_a/immutable/
|
From a8144cd98fdb08c1d942195f65fbc604f7bd3055 Mon Sep 17 00:00:00 2001
From: Ailin Nemui <[email protected]>
Date: Fri, 26 Feb 2021 20:25:48 +0100
Subject: [PATCH] skip parsing empty tags
Credit to OSS-Fuzz
---
src/irc/core/irc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index 96a09333b..a5bd608b0 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -433,6 +433,8 @@ GHashTable *irc_parse_message_tags(const char *tags)
(GDestroyNotify) i_refstr_release, (GDestroyNotify) g_free);
split = g_strsplit(tags, ";", -1);
for (tmp = split; *tmp != NULL; tmp++) {
+ if (*tmp[0] == '\0')
+ continue;
kv = g_strsplit(*tmp, "=", 2);
unescape_tag(kv[1]);
g_hash_table_replace(hash, i_refstr_intern(kv[0]),
|
3rdn4/irssi:b472570-heap_buffer_overflow_b
|
/workspace/skyset/
|
irssi
|
b472570-heap_buffer_overflow_b
|
/workspace/skyset/irssi/b472570-heap_buffer_overflow_b/report.txt
|
A heap buffer overflow b found in /workspace/skyset/irssi/b472570-heap_buffer_overflow_b/immutable/
|
From 4c069f5c8f3b63d8ba8556ba8292e1f5972508d6 Mon Sep 17 00:00:00 2001
From: Ailin Nemui <[email protected]>
Date: Sat, 27 Feb 2021 18:31:00 +0100
Subject: [PATCH] stop parsing on lone tag escape
It's C
Credit to OSS-Fuzz
---
src/irc/core/irc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index a5bd608b0..8ecda85b4 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -395,6 +395,8 @@ static void unescape_tag(char *tag)
for (; *tmp != '\0'; tmp++, tag++) {
if (*tmp == '\\') {
tmp++;
+ if (*tmp == '\0')
+ break;
switch (*tmp) {
case ':':
*tag = ';';
|
3rdn4/krb5:d864d74-heap_buffer_overflow
|
/workspace/skyset/
|
krb5
|
d864d74-heap_buffer_overflow
|
/workspace/skyset/krb5/d864d74-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/krb5/d864d74-heap_buffer_overflow/immutable/
|
From c5507dff5f5b2936937442b43f6c021b4f8a493d Mon Sep 17 00:00:00 2001
From: Greg Hudson <[email protected]>
Date: Sat, 10 Dec 2022 00:40:44 -0500
Subject: [PATCH] Simplify krb5_chpw_message() UTF-8 processing
Only validate the message as a UTF-8 string, rather than normalizing
it.
---
src/include/k5-unicode.h | 2 ++
src/lib/krb5/krb/chpw.c | 10 ++++------
src/lib/krb5/unicode/ucstr.c | 27 +++++++++++++++++++++++++++
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/src/include/k5-unicode.h b/src/include/k5-unicode.h
index e51ab2fe861..45c1788b264 100644
--- a/src/include/k5-unicode.h
+++ b/src/include/k5-unicode.h
@@ -127,4 +127,6 @@ int krb5int_utf8_normcmp(
const krb5_data *,
unsigned);
+krb5_boolean k5_utf8_validate(const krb5_data *data);
+
#endif /* K5_UNICODE_H */
diff --git a/src/lib/krb5/krb/chpw.c b/src/lib/krb5/krb/chpw.c
index cdec5952155..803c80febaf 100644
--- a/src/lib/krb5/krb/chpw.c
+++ b/src/lib/krb5/krb/chpw.c
@@ -477,7 +477,6 @@ krb5_chpw_message(krb5_context context, const krb5_data *server_string,
char **message_out)
{
krb5_error_code ret;
- krb5_data *string;
char *msg;
*message_out = NULL;
@@ -493,11 +492,10 @@ krb5_chpw_message(krb5_context context, const krb5_data *server_string,
/* If server_string contains a valid UTF-8 string, return that. */
if (server_string->length > 0 &&
memchr(server_string->data, 0, server_string->length) == NULL &&
- krb5int_utf8_normalize(server_string, &string,
- KRB5_UTF8_APPROX) == 0) {
- *message_out = string->data; /* already null terminated */
- free(string);
- return 0;
+ k5_utf8_validate(server_string)) {
+ *message_out = k5memdup0(server_string->data, server_string->length,
+ &ret);
+ return (*message_out == NULL) ? ENOMEM : 0;
}
/* server_string appears invalid, so try to be helpful. */
diff --git a/src/lib/krb5/unicode/ucstr.c b/src/lib/krb5/unicode/ucstr.c
index e3ed9bc64a1..0257882cd7e 100644
--- a/src/lib/krb5/unicode/ucstr.c
+++ b/src/lib/krb5/unicode/ucstr.c
@@ -18,6 +18,7 @@
#include "k5-int.h"
#include "k5-utf8.h"
#include "k5-unicode.h"
+#include "k5-input.h"
#include "ucdata/ucdata.h"
#include <ctype.h>
@@ -100,6 +101,32 @@ krb5int_ucstr2upper(
}
}
+/* Return true if data contains valid UTF-8 sequences. */
+krb5_boolean
+k5_utf8_validate(const krb5_data *data)
+{
+ struct k5input in;
+ int len, tmplen, i;
+ const uint8_t *bytes;
+
+ k5_input_init(&in, data->data, data->length);
+ while (!in.status && in.len > 0) {
+ len = KRB5_UTF8_CHARLEN(in.ptr);
+ if (len < 1 || len > 4)
+ return FALSE;
+ bytes = k5_input_get_bytes(&in, len);
+ if (bytes == NULL)
+ return FALSE;
+ if (KRB5_UTF8_CHARLEN2(bytes, tmplen) != len)
+ return FALSE;
+ for (i = 1; i < len; i++) {
+ if ((bytes[i] & 0xc0) != 0x80)
+ return FALSE;
+ }
+ }
+ return !in.status;
+}
+
#define TOUPPER(c) (islower(c) ? toupper(c) : (c))
#define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
|
3rdn4/libmobi:1297ee0-heap_out_of_bound
|
/workspace/skyset/
|
libmobi
|
1297ee0-heap_out_of_bound
|
/workspace/skyset/libmobi/1297ee0-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/libmobi/1297ee0-heap_out_of_bound/immutable/
|
diff --git a/src/parse_rawml.c b/src/parse_rawml.c
index 6b6c9d7..41ba9a3 100644
--- a/src/parse_rawml.c
+++ b/src/parse_rawml.c
@@ -107,7 +107,7 @@ MOBI_RET mobi_search_links_kf7(MOBIResult *result, const unsigned char *data_sta
result->value[i++] = (char) *data++;
}
/* self closing tag '/>' */
- if (*(data - 1) == '/' && *data == '>') {
+ if (data <= data_end && *(data - 1) == '/' && *data == '>') {
--data; --i;
}
result->end = data;
|
3rdn4/libmobi:4b60805-heap_out_of_bound
|
/workspace/skyset/
|
libmobi
|
4b60805-heap_out_of_bound
|
/workspace/skyset/libmobi/4b60805-heap_out_of_bound/report.txt
|
A heap out of bound found in /workspace/skyset/libmobi/4b60805-heap_out_of_bound/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 2eaf0fa..6a9e42c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,9 @@
+2022-04-26: Fix array boundary check when parsing inflections which could result in buffer over-read with corrupt input
2022-04-23: Fix formatting
2022-04-23: Fix checking boundary of deobfuscation key which could cause buffer over-read with corrupt data
2022-04-23: Fix issue with corrupt data with empty lookup string which could lead to read beyond buffer
-2022-04-23: Fix faulty checks for array boundary which caused buffer over-read
-2022-04-23: Fix issue with corrupt files with tagvalues_count = 0 that caused heap buffer over-read
+2022-04-23: Fix faulty checks for array boundary which caused buffer over-read with corrupt input
+2022-04-23: Fix issue with corrupt files with tagvalues_count = 0 that caused null pointer dereference
2022-04-23: Fix issues when mobi_buffer_getpointer returns null. With corrupt data this could lead to out-of-bounds read
2022-04-13: Add packaging status [skip ci]
2022-04-10: Make random generation return proper error codes
diff --git a/src/parse_rawml.c b/src/parse_rawml.c
index 681c665..6b6c9d7 100644
--- a/src/parse_rawml.c
+++ b/src/parse_rawml.c
@@ -1413,6 +1413,10 @@ MOBI_RET mobi_reconstruct_infl(char *outstring, const MOBIIndx *infl, const MOBI
unsigned char decoded[INDX_INFLBUF_SIZEMAX + 1];
memset(decoded, 0, INDX_INFLBUF_SIZEMAX + 1);
+ if (parts[j] >= infl->entries_count) {
+ debug_print("%s\n", "Invalid entry offset");
+ return MOBI_DATA_CORRUPT;
+ }
unsigned char *rule = (unsigned char *) infl->entries[parts[j]].label;
memcpy(decoded, label, label_length);
int decoded_length = (int) label_length;
|
3rdn4/libmobi:afa8ce1-stack_out_of_bound
|
/workspace/skyset/
|
libmobi
|
afa8ce1-stack_out_of_bound
|
/workspace/skyset/libmobi/afa8ce1-stack_out_of_bound/report.txt
|
A stack out of bound found in /workspace/skyset/libmobi/afa8ce1-stack_out_of_bound/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 8171034..b431347 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+2022-04-27: Fix wrong boundary checks in inflections parser resulting in stack buffer over-read with corrupt input
2022-04-26: Fix text formatting
2022-04-26: Fix array boundary check when parsing inflections which could result in buffer over-read with corrupt input
2022-04-23: Fix formatting
diff --git a/src/index.c b/src/index.c
index 7e4f3b7..ca83675 100644
--- a/src/index.c
+++ b/src/index.c
@@ -961,17 +961,13 @@ MOBI_RET mobi_decode_infl(unsigned char *decoded, int *decoded_size, const unsig
}
pos -= c - 10;
dir = 0;
- if (pos < 0 || pos > *decoded_size) {
- debug_print("Position setting failed (%s)\n", decoded);
- return MOBI_DATA_CORRUPT;
- }
}
else {
if (mod == 'i') {
const unsigned char *s = decoded + pos;
unsigned char *d = decoded + pos + 1;
const int l = *decoded_size - pos;
- if (l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {
+ if (pos < 0 || l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {
debug_print("Out of buffer in %s at pos: %i\n", decoded, pos);
return MOBI_DATA_CORRUPT;
}
@@ -984,7 +980,7 @@ MOBI_RET mobi_decode_infl(unsigned char *decoded, int *decoded_size, const unsig
const unsigned char *s = decoded + pos + 1;
unsigned char *d = decoded + pos;
const int l = *decoded_size - pos;
- if (l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {
+ if (pos < 0 || l < 0 || s + l > decoded + INDX_INFLBUF_SIZEMAX) {
debug_print("Out of buffer in %s at pos: %i\n", decoded, pos);
return MOBI_DATA_CORRUPT;
}
|
3rdn4/libmobi:eafc415-null_pointer_deref
|
/workspace/skyset/
|
libmobi
|
eafc415-null_pointer_deref
|
/workspace/skyset/libmobi/eafc415-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/libmobi/eafc415-null_pointer_deref/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index b431347..8f48750 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+2022-04-27: Fix undefined behavior when passing null to strdup
2022-04-27: Fix wrong boundary checks in inflections parser resulting in stack buffer over-read with corrupt input
2022-04-26: Fix text formatting
2022-04-26: Fix array boundary check when parsing inflections which could result in buffer over-read with corrupt input
diff --git a/src/opf.c b/src/opf.c
index eb36750..02e984b 100644
--- a/src/opf.c
+++ b/src/opf.c
@@ -1152,24 +1152,30 @@ MOBI_RET mobi_build_opf_metadata(OPF *opf, const MOBIData *m, const MOBIRawml *
if (mobi_is_dictionary(m)) {
if (opf->metadata->x_meta->dictionary_in_lang == NULL) {
if (m->mh && m->mh->dict_input_lang) {
- opf->metadata->x_meta->dictionary_in_lang = calloc(OPF_META_MAX_TAGS, sizeof(char*));
- if (opf->metadata->x_meta->dictionary_in_lang == NULL) {
- debug_print("%s\n", "Memory allocation failed");
- return MOBI_MALLOC_FAILED;
- }
uint32_t dict_lang_in = *m->mh->dict_input_lang;
- opf->metadata->x_meta->dictionary_in_lang[0] = strdup(mobi_get_locale_string(dict_lang_in));
+ const char *lang = mobi_get_locale_string(dict_lang_in);
+ if (lang) {
+ opf->metadata->x_meta->dictionary_in_lang = calloc(OPF_META_MAX_TAGS, sizeof(char*));
+ if (opf->metadata->x_meta->dictionary_in_lang == NULL) {
+ debug_print("%s\n", "Memory allocation failed");
+ return MOBI_MALLOC_FAILED;
+ }
+ opf->metadata->x_meta->dictionary_in_lang[0] = strdup(lang);
+ }
}
}
if (opf->metadata->x_meta->dictionary_out_lang == NULL) {
if (m->mh && m->mh->dict_output_lang) {
- opf->metadata->x_meta->dictionary_out_lang = calloc(OPF_META_MAX_TAGS, sizeof(char*));
- if (opf->metadata->x_meta->dictionary_out_lang == NULL) {
- debug_print("%s\n", "Memory allocation failed");
- return MOBI_MALLOC_FAILED;
+ uint32_t dict_lang_out = *m->mh->dict_output_lang;
+ const char *lang = mobi_get_locale_string(dict_lang_out);
+ if (lang) {
+ opf->metadata->x_meta->dictionary_out_lang = calloc(OPF_META_MAX_TAGS, sizeof(char*));
+ if (opf->metadata->x_meta->dictionary_out_lang == NULL) {
+ debug_print("%s\n", "Memory allocation failed");
+ return MOBI_MALLOC_FAILED;
+ }
+ opf->metadata->x_meta->dictionary_out_lang[0] = strdup(lang);
}
- uint32_t dict_lang_in = *m->mh->dict_output_lang;
- opf->metadata->x_meta->dictionary_out_lang[0] = strdup(mobi_get_locale_string(dict_lang_in));
}
}
if (rawml->orth->orth_index_name) {
diff --git a/src/util.c b/src/util.c
index d0d57dd..a9260d4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -641,7 +641,7 @@ static const char *mobi_locale[MOBI_LANG_MAX][MOBI_REGION_MAX] = {
See mobi_locale array.
@param[in] locale_number Mobipocket locale number (as stored in MOBI header)
- @return Pointer to locale string in mobi_locale array
+ @return Pointer to locale string in mobi_locale array or NULL on error
*/
const char * mobi_get_locale_string(const uint32_t locale_number) {
uint8_t lang_code = locale_number & 0xffU;
diff --git a/tools/common.c b/tools/common.c
index 6c7cbfe..d26f37c 100644
--- a/tools/common.c
+++ b/tools/common.c
@@ -330,7 +330,7 @@ void print_summary(const MOBIData *m) {
*m->mh->dict_input_lang && *m->mh->dict_output_lang) {
const char *locale_in = mobi_get_locale_string(*m->mh->dict_input_lang);
const char *locale_out = mobi_get_locale_string(*m->mh->dict_output_lang);
- printf(": %s => %s", locale_in, locale_out);
+ printf(": %s => %s", locale_in ? locale_in : "unknown", locale_out ? locale_out : "unknown");
}
printf("\n");
}
|
3rdn4/libmobi:eb4a262-null_pointer_deref
|
/workspace/skyset/
|
libmobi
|
eb4a262-null_pointer_deref
|
/workspace/skyset/libmobi/eb4a262-null_pointer_deref/report.txt
|
A null pointer deref found in /workspace/skyset/libmobi/eb4a262-null_pointer_deref/immutable/
|
diff --git a/ChangeLog b/ChangeLog
index 5d9ab5c..e385bfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+2022-05-27: Fix potential null pointer dereference on corrupt input when inflections CNCX record is not initialized
2022-05-23: Fix index entries count
2022-05-23: Prevent leak of index entries on corrupt data
2022-05-23: Add checks for fragments part in case of corrupt data
diff --git a/src/index.c b/src/index.c
index 322f2de..f8ad74f 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1019,14 +1019,14 @@ MOBI_RET mobi_decode_infl(unsigned char *decoded, int *decoded_size, const unsig
Matches are made agains reversed string and all its substrings
@param[in,out] infl_strings Array of returned strings
- @param[in,out] root Root node of the tree
- @param[in,out] string Index entry number
+ @param[in] root Root node of the tree
+ @param[in] string Index entry number
@return Number of returned strings
*/
size_t mobi_trie_get_inflgroups(char **infl_strings, MOBITrie * const root, const char *string) {
/* travers trie and get values for each substring */
if (root == NULL) {
- return MOBI_PARAM_ERR;
+ return 0;
}
size_t count = 0;
size_t length = strlen(string);
@@ -1060,11 +1060,14 @@ size_t mobi_trie_get_inflgroups(char **infl_strings, MOBITrie * const root, cons
@brief Insert inversed inlection string for given entry into trie structure
@param[in,out] root Root node of the tree, created if NULL
- @param[in,out] indx MOBIIndx infl index records
- @param[in,out] i Index entry number
+ @param[in] indx MOBIIndx infl index records
+ @param[in] i Index entry number
@return MOBI_RET status code (on success MOBI_SUCCESS)
*/
MOBI_RET mobi_trie_insert_infl(MOBITrie **root, const MOBIIndx *indx, size_t i) {
+ if (indx->cncx_record == NULL) {
+ return MOBI_DATA_CORRUPT;
+ }
MOBIIndexEntry e = indx->entries[i];
char *inflected = e.label;
for (size_t j = 0; j < e.tags_count; j++) {
|
3rdn4/libplist:491a3ac-heap_buffer_overflow_a
|
/workspace/skyset/
|
libplist
|
491a3ac-heap_buffer_overflow_a
|
/workspace/skyset/libplist/491a3ac-heap_buffer_overflow_a/report.txt
|
A heap buffer overflow a found in /workspace/skyset/libplist/491a3ac-heap_buffer_overflow_a/immutable/
|
From 5bdbd3fe620e66a65373524a0707909ca926a3a1 Mon Sep 17 00:00:00 2001
From: Nikias Bassen <[email protected]>
Date: Mon, 9 Jan 2023 19:07:54 +0100
Subject: [PATCH] oplist: Fix OOB read by checking bounds properly
Credit to OSS-Fuzz
---
src/oplist.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/oplist.c b/src/oplist.c
index df12fb3e..21d8a644 100644
--- a/src/oplist.c
+++ b/src/oplist.c
@@ -550,7 +550,7 @@ static void parse_dict_data(parse_ctx ctx, plist_t dict)
if (ctx->pos >= ctx->end) {
PLIST_OSTEP_ERR("EOF while parsing dictionary item at offset %ld\n", ctx->pos - ctx->start);
ctx->err++;
- break;
+ break;
}
val = NULL;
ctx->err = node_from_openstep(ctx, &val);
@@ -710,6 +710,11 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
}
ctx->pos++;
}
+ if (ctx->pos >= ctx->end) {
+ PLIST_OSTEP_ERR("EOF while parsing quoted string at offset %ld\n", ctx->pos - ctx->start);
+ ctx->err++;
+ goto err_out;
+ }
if (*ctx->pos != c) {
plist_free_data(data);
PLIST_OSTEP_ERR("Missing closing quote (%c) at offset %ld\n", c, ctx->pos - ctx->start);
|
3rdn4/libplist:491a3ac-heap_buffer_overflow_b
|
/workspace/skyset/
|
libplist
|
491a3ac-heap_buffer_overflow_b
|
/workspace/skyset/libplist/491a3ac-heap_buffer_overflow_b/report.txt
|
A heap buffer overflow b found in /workspace/skyset/libplist/491a3ac-heap_buffer_overflow_b/immutable/
|
From 85f5cbd3705b34fcc52009ca51d8167ab18764fa Mon Sep 17 00:00:00 2001
From: Nikias Bassen <[email protected]>
Date: Tue, 17 Jan 2023 01:26:58 +0100
Subject: [PATCH] oplist: Fix another OOB read
Credit to OSS-Fuzz
---
...rfuzz-testcase-minimized-oplist_fuzzer-4716194114699264 | 1 +
src/oplist.c | 7 +++++++
2 files changed, 8 insertions(+)
create mode 100644 fuzz/oplist-crashes/clusterfuzz-testcase-minimized-oplist_fuzzer-4716194114699264
diff --git a/fuzz/oplist-crashes/clusterfuzz-testcase-minimized-oplist_fuzzer-4716194114699264 b/fuzz/oplist-crashes/clusterfuzz-testcase-minimized-oplist_fuzzer-4716194114699264
new file mode 100644
index 00000000..2fa08dcb
--- /dev/null
+++ b/fuzz/oplist-crashes/clusterfuzz-testcase-minimized-oplist_fuzzer-4716194114699264
@@ -0,0 +1 @@
+(<
\ No newline at end of file
diff --git a/src/oplist.c b/src/oplist.c
index 8936cce2..4dd0df5d 100644
--- a/src/oplist.c
+++ b/src/oplist.c
@@ -715,6 +715,13 @@ static int node_from_openstep(parse_ctx ctx, plist_t *plist)
plist_free_data(data);
goto err_out;
}
+ if (ctx->pos >= ctx->end) {
+ byte_array_free(bytes);
+ plist_free_data(data);
+ PLIST_OSTEP_ERR("EOF while parsing data terminator '>' at offset %ld\n", ctx->pos - ctx->start);
+ ctx->err++;
+ goto err_out;
+ }
if (*ctx->pos != '>') {
byte_array_free(bytes);
plist_free_data(data);
|
3rdn4/libplist:491a3ac-heap_use_after_free
|
/workspace/skyset/
|
libplist
|
491a3ac-heap_use_after_free
|
/workspace/skyset/libplist/491a3ac-heap_use_after_free/report.txt
|
A heap use after free found in /workspace/skyset/libplist/491a3ac-heap_use_after_free/immutable/
|
From 62b03b85a56a7b98e6eef237deeff1a8b41f8fb8 Mon Sep 17 00:00:00 2001
From: Nikias Bassen <[email protected]>
Date: Mon, 9 Jan 2023 19:01:14 +0100
Subject: [PATCH] oplist: Fix use-after-free by setting free'd pointer to NULL
Credit to OSS-Fuzz
---
src/oplist.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/oplist.c b/src/oplist.c
index b3b782fc..df12fb3e 100644
--- a/src/oplist.c
+++ b/src/oplist.c
@@ -851,6 +851,7 @@ PLIST_API int plist_from_openstep(const char *plist_ostep, uint32_t length, plis
} else if (ctx.pos < ctx.end && *ctx.pos == '=') {
/* attempt to parse this as 'strings' data */
plist_free(*plist);
+ *plist = NULL;
plist_t pl = plist_new_dict();
ctx.pos = plist_ostep;
parse_dict_data(&ctx, pl);
|
3rdn4/libsndfile:2b4cc4b-heap_buffer_overflow
|
/workspace/skyset/
|
libsndfile
|
2b4cc4b-heap_buffer_overflow
|
/workspace/skyset/libsndfile/2b4cc4b-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/libsndfile/2b4cc4b-heap_buffer_overflow/immutable/
|
From 3970faeb7fc8cee60cc5260ab4102433c37d5d63 Mon Sep 17 00:00:00 2001
From: bobsayshilol <[email protected]>
Date: Sun, 14 Feb 2021 13:09:18 +0000
Subject: [PATCH] Make sure that there's enough space to store decoded nibbles
in when reading IMA ADPCM data
The loop in wavlike_ima_decode_block() that pulls apart the nibbles
assumes that there's 8 nibbles worth of data for every channel, so
rather than adding a branch in the hot path I've opted for allocating
slightly more than we might need.
This was a blocker caught by fuzzing locally.
This also appears to be the same crash as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25530.
---
src/ima_adpcm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/ima_adpcm.c b/src/ima_adpcm.c
index 8c9bbff3e..28c20ca32 100644
--- a/src/ima_adpcm.c
+++ b/src/ima_adpcm.c
@@ -182,7 +182,12 @@ ima_reader_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
if (psf->file.mode != SFM_READ)
return SFE_BAD_MODE_RW ;
- pimasize = sizeof (IMA_ADPCM_PRIVATE) + blockalign * psf->sf.channels + 3 * psf->sf.channels * samplesperblock ;
+ /*
+ ** Allocate enough space for 1 more than a multiple of 8 samples
+ ** to avoid having to branch when pulling apart the nibbles.
+ */
+ count = ((samplesperblock - 2) | 7) + 2 ;
+ pimasize = sizeof (IMA_ADPCM_PRIVATE) + psf->sf.channels * (blockalign + samplesperblock + sizeof(short) * count) ;
if (! (pima = calloc (1, pimasize)))
return SFE_MALLOC_FAILED ;
|
3rdn4/libsndfile:4819cad-heap_buffer_overflow
|
/workspace/skyset/
|
libsndfile
|
4819cad-heap_buffer_overflow
|
/workspace/skyset/libsndfile/4819cad-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/libsndfile/4819cad-heap_buffer_overflow/immutable/
|
From deb669ee8be55a94565f6f8a6b60890c2e7c6f32 Mon Sep 17 00:00:00 2001
From: bobsayshilol <[email protected]>
Date: Thu, 18 Feb 2021 21:52:09 +0000
Subject: [PATCH] ms_adpcm: Fix and extend size checks
'blockalign' is the size of a block, and each block contains 7 samples
per channel as part of the preamble, so check against 'samplesperblock'
rather than 'blockalign'. Also add an additional check that the block
is big enough to hold the samples it claims to hold.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26803
---
src/ms_adpcm.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/ms_adpcm.c b/src/ms_adpcm.c
index 5e8f1a316..a21cb9941 100644
--- a/src/ms_adpcm.c
+++ b/src/ms_adpcm.c
@@ -128,8 +128,14 @@ wavlike_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock)
if (psf->file.mode == SFM_WRITE)
samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ;
- if (blockalign < 7 * psf->sf.channels)
- { psf_log_printf (psf, "*** Error blockalign (%d) should be > %d.\n", blockalign, 7 * psf->sf.channels) ;
+ /* There's 7 samples per channel in the preamble of each block */
+ if (samplesperblock < 7 * psf->sf.channels)
+ { psf_log_printf (psf, "*** Error samplesperblock (%d) should be >= %d.\n", samplesperblock, 7 * psf->sf.channels) ;
+ return SFE_INTERNAL ;
+ } ;
+
+ if (2 * blockalign < samplesperblock * psf->sf.channels)
+ { psf_log_printf (psf, "*** Error blockalign (%d) should be >= %d.\n", blockalign, samplesperblock * psf->sf.channels / 2) ;
return SFE_INTERNAL ;
} ;
|
3rdn4/libsndfile:932aead-negative_size_param
|
/workspace/skyset/
|
libsndfile
|
932aead-negative_size_param
|
/workspace/skyset/libsndfile/932aead-negative_size_param/report.txt
|
A negative size param found in /workspace/skyset/libsndfile/932aead-negative_size_param/immutable/
|
From 1998691e5687037a77b5addd4ca7533bfbe90553 Mon Sep 17 00:00:00 2001
From: Max Dymond <[email protected]>
Date: Thu, 22 Oct 2020 10:10:12 +0100
Subject: [PATCH] Fix up the fuzzer so that it can't under or overseek.
Instead, print out the bad seek, e.g.
```
Running: /out/clusterfuzz-testcase-minimized-sndfile_fuzzer-4838501290606592
vf overseek: new_offset(539033364) > vf->length(20); whence(1), vf->offset(20), offset(539033344)
vf overseek: new_offset(539033364) > vf->length(20); whence(1), vf->offset(20), offset(539033344)
```
---
ossfuzz/sndfile_fuzzer.cc | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/ossfuzz/sndfile_fuzzer.cc b/ossfuzz/sndfile_fuzzer.cc
index 6c663b1ba..3c850730e 100644
--- a/ossfuzz/sndfile_fuzzer.cc
+++ b/ossfuzz/sndfile_fuzzer.cc
@@ -3,6 +3,7 @@
#include <string.h>
#include <sys/types.h>
#include <sndfile.h>
+#include <inttypes.h>
typedef struct
{
@@ -20,25 +21,45 @@ static sf_count_t vfget_filelen (void *user_data)
static sf_count_t vfseek (sf_count_t offset, int whence, void *user_data)
{
VIO_DATA *vf = (VIO_DATA *)user_data;
+ sf_count_t new_offset;
switch (whence)
{
case SEEK_SET:
- vf->offset = offset;
+ new_offset = offset;
break ;
case SEEK_CUR:
- vf->offset = vf->offset + offset;
+ new_offset = vf->offset + offset;
break ;
case SEEK_END:
- vf->offset = vf->length + offset;
+ new_offset = vf->length + offset;
break;
default:
break;
}
+ /* Ensure you can't seek outside the data */
+ if (new_offset > vf->length)
+ {
+ /* Trying to seek past the end of the data */
+ printf("vf overseek: new_offset(%" PRId64 ") > vf->length(%" PRId64 ");"
+ " whence(%d), vf->offset(%" PRId64 "), offset(%" PRId64 ")\n",
+ new_offset, vf->length, whence, vf->offset, offset);
+ new_offset = vf->length;
+ }
+ else if (new_offset < 0)
+ {
+ /* Trying to seek before the start of the data */
+ printf("vf underseek: new_offset(%" PRId64 ") < 0; whence(%d), vf->offset"
+ "(%" PRId64 "), vf->length(%" PRId64 "), offset(%" PRId64 ")\n",
+ new_offset, whence, vf->offset, vf->length, offset);
+ new_offset = 0;
+ }
+ vf->offset = new_offset;
+
return vf->offset;
}
|
3rdn4/libsndfile:b706e62-heap_buffer_overflow
|
/workspace/skyset/
|
libsndfile
|
b706e62-heap_buffer_overflow
|
/workspace/skyset/libsndfile/b706e62-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/libsndfile/b706e62-heap_buffer_overflow/immutable/
|
From 949c89122d1081d69260a16a56350624c4db5916 Mon Sep 17 00:00:00 2001
From: bobsayshilol <[email protected]>
Date: Sun, 25 Apr 2021 19:10:07 +0100
Subject: [PATCH] ALAC: Enable release check from original code
The original code that this was copied from only disabled this check in
debug builds as described in the comment, however doing so also allows
`channelIndex` to increase without bounds and can lead to writing past
the end of the output buffer.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27503
---
src/ALAC/alac_decoder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ALAC/alac_decoder.c b/src/ALAC/alac_decoder.c
index 52b7a4868..46d333060 100644
--- a/src/ALAC/alac_decoder.c
+++ b/src/ALAC/alac_decoder.c
@@ -554,7 +554,7 @@ alac_decode (ALAC_DECODER *p, struct BitBuffer * bits, int32_t * sampleBuffer, u
}
}
-#if 0 // ! DEBUG
+#if 1 // ! DEBUG
// if we've decoded all of our channels, bail (but not in debug b/c we want to know if we're seeing bad bits)
// - this also protects us if the config does not match the bitstream or crap data bits follow the audio bits
if (channelIndex >= numChannels)
|
3rdn4/libsndfile:fe49327-heap_buffer_overflow
|
/workspace/skyset/
|
libsndfile
|
fe49327-heap_buffer_overflow
|
/workspace/skyset/libsndfile/fe49327-heap_buffer_overflow/report.txt
|
A heap buffer overflow found in /workspace/skyset/libsndfile/fe49327-heap_buffer_overflow/immutable/
|
From a9815b3f228df00086e0a40bcc43162fc19896a1 Mon Sep 17 00:00:00 2001
From: bobsayshilol <[email protected]>
Date: Wed, 17 Feb 2021 23:21:48 +0000
Subject: [PATCH] wavlike: Fix incorrect size check
The SF_CART_INFO_16K struct has an additional 4 byte field to hold
the size of 'tag_text' which the file header doesn't, so don't
include it as part of the check when looking for the max length.
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26026
---
src/wavlike.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/wavlike.c b/src/wavlike.c
index b59c6847c..1c1ed2cf8 100644
--- a/src/wavlike.c
+++ b/src/wavlike.c
@@ -830,7 +830,11 @@ wavlike_read_cart_chunk (SF_PRIVATE *psf, uint32_t chunksize)
return 0 ;
} ;
- if (chunksize >= sizeof (SF_CART_INFO_16K))
+ /*
+ ** SF_CART_INFO_16K has an extra field 'tag_text_size' that isn't part
+ ** of the chunk, so don't include it in the size check.
+ */
+ if (chunksize >= sizeof (SF_CART_INFO_16K) - 4)
{ psf_log_printf (psf, "cart : %u too big to be handled\n", chunksize) ;
psf_binheader_readf (psf, "j", chunksize) ;
return 0 ;
|
3rdn4/libtpms:e563166-stack_buffer_overflow
|
/workspace/skyset/
|
libtpms
|
e563166-stack_buffer_overflow
|
/workspace/skyset/libtpms/e563166-stack_buffer_overflow/report.txt
|
A stack buffer overflow found in /workspace/skyset/libtpms/e563166-stack_buffer_overflow/immutable/
|
From 034a5c02488cf7f0048e130177fc71c9e626e135 Mon Sep 17 00:00:00 2001
From: Stefan Berger <[email protected]>
Date: Fri, 23 Jul 2021 13:29:00 -0400
Subject: [PATCH] tpm2: NVMarshal: Handle index orderly RAM without 0-sized
terminating node
The NVRAM entries in s_indexOrderlyRam array do not need to contain a
0-sized terminating node. Instead, the entries may fill up this 512
byte array so that no NV_RAM_HEADER structure fits anymore. The fact
that no more NV_RAM_HEADER structure fits is also an indicator for the
last entry. We need to account for this in the code marshalling and
unmarshalling the entries so that we stop marshalling the entries
then and similarly stop unmarshalling.
Signed-off-by: Stefan Berger <[email protected]>
---
src/tpm2/NVMarshal.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/tpm2/NVMarshal.c b/src/tpm2/NVMarshal.c
index 8e0ec0b4d..e3db9d644 100644
--- a/src/tpm2/NVMarshal.c
+++ b/src/tpm2/NVMarshal.c
@@ -4269,6 +4269,12 @@ INDEX_ORDERLY_RAM_Marshal(void *array, size_t array_size,
datasize, buffer, size);
}
offset += nrh.size;
+ if (offset + sizeof(NV_RAM_HEADER) > array_size) {
+ /* nothing will fit anymore and there won't be a 0-sized
+ * terminating node (@1).
+ */
+ break;
+ }
}
written += BLOCK_SKIP_WRITE_PUSH(TRUE, buffer, size);
@@ -4311,6 +4317,16 @@ INDEX_ORDERLY_RAM_Unmarshal(void *array, size_t array_size,
*/
nrhp = array + offset;
+ if (offset + sizeof(NV_RAM_HEADER) > sourceside_size) {
+ /* this case can occur with the previous entry filling up the
+ * space; in this case there will not be a 0-sized terminating
+ * node (see @1 above). We clear the rest of our space.
+ */
+ if (array_size > offset)
+ memset(nrhp, 0, array_size - offset);
+ break;
+ }
+
/* write the NVRAM header;
nrh->size holds the complete size including data;
nrh->size = 0 indicates the end */
|
3rdn4/libxml2:20f5c73-global_buffer_overflow
|
/workspace/skyset/
|
libxml2
|
20f5c73-global_buffer_overflow
|
/workspace/skyset/libxml2/20f5c73-global_buffer_overflow/report.txt
|
A global buffer overflow found in /workspace/skyset/libxml2/20f5c73-global_buffer_overflow/immutable/
|
From b236b7a588ac2973a057ec578011cdc17c26f16d Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <[email protected]>
Date: Thu, 8 Jun 2023 21:53:05 +0200
Subject: [PATCH] parser: Halt parser when growing buffer results in OOM
Fix short-lived regression from previous commit.
It might be safer to make xmlBufSetInputBaseCur use the original buffer
even in case of errors.
Found by OSS-Fuzz.
---
buf.c | 4 ++++
encoding.c | 4 +++-
parserInternals.c | 6 +++++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/buf.c b/buf.c
index f876ea99f..fbaf926a6 100644
--- a/buf.c
+++ b/buf.c
@@ -1100,6 +1100,10 @@ xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
size_t base, size_t cur) {
if (input == NULL)
return(-1);
+ /*
+ * TODO: It might be safer to keep using the buffer content if there
+ * was an error.
+ */
if ((buf == NULL) || (buf->error)) {
input->base = input->cur = input->end = BAD_CAST "";
return(-1);
diff --git a/encoding.c b/encoding.c
index 0a1b48678..3d461cd37 100644
--- a/encoding.c
+++ b/encoding.c
@@ -2143,8 +2143,10 @@ xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
toconv = 64 * 1024;
written = xmlBufAvail(out);
if (toconv * 2 >= written) {
- if (xmlBufGrow(out, toconv * 2) < 0)
+ if (xmlBufGrow(out, toconv * 2) < 0) {
+ input->error = XML_ERR_NO_MEMORY;
return(XML_ENC_ERR_MEMORY);
+ }
written = xmlBufAvail(out);
}
if ((written > 128 * 1024) && (flush == 0))
diff --git a/parserInternals.c b/parserInternals.c
index bc65c6312..5c267cd2a 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -566,8 +566,12 @@ xmlParserGrow(xmlParserCtxtPtr ctxt) {
ret = xmlParserInputBufferGrow(buf, INPUT_CHUNK);
xmlBufSetInputBaseCur(buf->buffer, in, 0, curBase);
- if (ret < 0)
+ if (ret < 0) {
xmlFatalErr(ctxt, buf->error, NULL);
+ /* Buffer contents may be lost in case of memory errors. */
+ if (buf->error == XML_ERR_NO_MEMORY)
+ xmlHaltParser(ctxt);
+ }
return(ret);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.