From dcfea6ce82cb8be41085051903ae068fc37c49f9 Mon Sep 17 00:00:00 2001 From: Angie Date: Fri, 8 Mar 2024 21:35:12 -0300 Subject: [PATCH 1/2] Fix possible stack overflow if `immOverride` is larger than 255 bytes --- CHANGELOG.md | 4 ++++ .../RabbitizerInstruction_Operand.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03376401..18dbf3f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix possible stack overflow if `immOverride` is larger than 255 bytes. + ## [1.9.1] - 2024-02-18 ### Fixed diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c index 29ad455a..57ccfc6a 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c @@ -4,14 +4,16 @@ #include "instructions/RabbitizerInstruction.h" #include +#include #include "generated/instrOpercandCallbacks_array.h" size_t RabbitizerOperandType_getBufferSize(RabbitizerOperandType operand, const RabbitizerInstruction *instr, size_t immOverrideLength) { - char auxBuffer[0x100] = { 0 }; - char immOverride[0x100] = { 0 }; + char *auxBuffer = calloc(immOverrideLength * 2 + 2, sizeof(char)); + char *immOverride = calloc(immOverrideLength + 2, sizeof(char)); OperandCallback callback; + size_t size; assert(operand > RAB_OPERAND_ALL_INVALID); assert(operand < RAB_OPERAND_ALL_MAX); @@ -19,7 +21,12 @@ size_t RabbitizerOperandType_getBufferSize(RabbitizerOperandType operand, const callback = instrOpercandCallbacks[operand]; assert(callback != NULL); - return callback(instr, auxBuffer, immOverride, immOverrideLength); + size = callback(instr, auxBuffer, immOverride, immOverrideLength); + + free(auxBuffer); + free(immOverride); + + return size; } size_t RabbitizerInstruction_getSizeForBufferOperandsDisasm(const RabbitizerInstruction *self, From d717d29f0f6befb4b5c1ea2145d6b30427700e94 Mon Sep 17 00:00:00 2001 From: angie Date: Sun, 10 Mar 2024 11:06:53 -0300 Subject: [PATCH 2/2] version bump --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- README.md | 4 ++-- include/common/RabbitizerVersion.h | 2 +- pyproject.toml | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dbf3f7..a0398b85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.9.2] - 2024-03-10 + ### Fixed - Fix possible stack overflow if `immOverride` is larger than 255 bytes. @@ -552,6 +554,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First version [unreleased]: https://github.com/Decompollaborate/rabbitizer/compare/master...develop +[1.9.2]: https://github.com/Decompollaborate/rabbitizer/compare/1.9.1...1.9.2 [1.9.1]: https://github.com/Decompollaborate/rabbitizer/compare/1.9.0...1.9.1 [1.9.0]: https://github.com/Decompollaborate/rabbitizer/compare/1.8.3...1.9.0 [1.8.3]: https://github.com/Decompollaborate/rabbitizer/compare/1.8.2...1.8.3 diff --git a/Cargo.toml b/Cargo.toml index acb7eff0..1f22ee4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.9.1" +version = "1.9.2" edition = "2021" authors = ["Anghelo Carvajal "] description = "MIPS instruction decoder" diff --git a/README.md b/README.md index 78566d27..626a7e11 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ In order to keep it simple and fast the following features will not be added: The recommended way to install is using from the PyPi release, via `pip`: ```bash -pip install rabbitizer +pip install -U rabbitizer ``` In case you want to mess with the latest development version without wanting to @@ -82,7 +82,7 @@ cargo add rabbitizer Or you can add it manually to your `Cargo.toml`: ```toml -rabbitizer = "1.9.1" +rabbitizer = "1.9.2" ``` See this crate at . diff --git a/include/common/RabbitizerVersion.h b/include/common/RabbitizerVersion.h index f85bd309..859e2125 100644 --- a/include/common/RabbitizerVersion.h +++ b/include/common/RabbitizerVersion.h @@ -14,7 +14,7 @@ extern "C" { // Header version #define RAB_VERSION_MAJOR 1 #define RAB_VERSION_MINOR 9 -#define RAB_VERSION_PATCH 1 +#define RAB_VERSION_PATCH 2 #define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH) diff --git a/pyproject.toml b/pyproject.toml index c167e00c..23fc24ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ [project] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.9.1" +version = "1.9.2" description = "MIPS instruction decoder" # license = "MIT" readme = "README.md"