forked from lloyd/yajl
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The patch uses an abort() to prevent heap memory corruption, but per the discussion here lloyd#240 it seems that's the best option available without a significant rewrite of the library.
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Description: Fix for CVE-2022-24795 | ||
An integer overflow will lead to heap memory corruption with large (~2GB) inputs. | ||
Origin: https://github.com/ppisar/yajl/commit/23cea2d7677e396efed78bbf1bf153961fab6bad | ||
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040036 | ||
Bug: https://github.com/lloyd/yajl/issues/239 | ||
--- | ||
src/yajl_buf.c | 12 +++++++++++- | ||
1 file changed, 11 insertions(+), 1 deletion(-) | ||
|
||
--- a/src/yajl_buf.c | ||
+++ b/src/yajl_buf.c | ||
@@ -45,7 +45,17 @@ | ||
|
||
need = buf->len; | ||
|
||
- while (want >= (need - buf->used)) need <<= 1; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jstamp
Author
Owner
|
||
+ if (((buf->used > want) ? buf->used : want) > (size_t)(buf->used + want)) { | ||
+ /* We cannot allocate more memory than SIZE_MAX. */ | ||
+ abort(); | ||
+ } | ||
+ while (want >= (need - buf->used)) { | ||
+ if (need >= (size_t)((size_t)(-1)<<1)>>1) { | ||
+ /* need would overflow. */ | ||
+ abort(); | ||
+ } | ||
+ need <<= 1; | ||
+ } | ||
|
||
if (need != buf->len) { | ||
buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dynamically-link-tools.patch | ||
multiarch.patch | ||
CVE-2017-16516.patch | ||
CVE-2022-24795.patch | ||
CVE-2023-33460.patch |
I think this should be
while (need && want >= (need - buf->used)) need <<= 1;
See:
https://github.com/brianmario/yajl-ruby/pull/211/files#r871257171
robohack/yajl@166b384