diff --git a/CHANGELOG.md b/CHANGELOG.md index f7b40e9b..b36e7cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ New release of the HyperDbg Debugger. - Resync serial stream on framing overflow instead of flooding the debuggee, thanks to [@munraimix](https://github.com/munraimix) ([link](https://github.com/HyperDbg/HyperDbg/pull/663))([link](https://github.com/HyperDbg/HyperDbg/issues/661)) - Resync libhyperdbg's serial receivers on framing overflow too, thanks to [@munraimix](https://github.com/munraimix) ([link](https://github.com/HyperDbg/HyperDbg/pull/663))([link](https://github.com/HyperDbg/HyperDbg/issues/661)) - Updated Linux port documentation ([link](https://github.com/HyperDbg/HyperDbg/commit/622ea9df9730e3fe0a8ff22f035772631308ac36)) +- Applied cleanup for resync serial codes ([link](https://github.com/HyperDbg/HyperDbg/commit/a24c8c0a91485132ac9e28bfb588a689c8359359)) +- Fix memory-safety and robustness issues in the script engine and the PCI ID parser, thanks to [@enzo-berry](https://github.com/enzo-berry) ([link](https://github.com/HyperDbg/HyperDbg/pull/665)) ### Removed - Removed unused serial codes ([link](https://github.com/HyperDbg/HyperDbg/commit/b77df6a62bacf4bff29198b3d1acd7961a3e7f38)) diff --git a/hyperdbg/libhyperdbg/code/debugger/misc/pci-id.cpp b/hyperdbg/libhyperdbg/code/debugger/misc/pci-id.cpp index 11dcc467..92034535 100644 --- a/hyperdbg/libhyperdbg/code/debugger/misc/pci-id.cpp +++ b/hyperdbg/libhyperdbg/code/debugger/misc/pci-id.cpp @@ -114,7 +114,7 @@ GetVendorByIdStr(const CHAR * Filename, const CHAR * VendorId) if (f == NULL) { - ShowMessages("Error: Cannot open file '%s': error %d\n", Filename, errno); + ShowMessages("err, cannot open file '%s' (error 0x%x)\n", Filename, errno); return NULL; } @@ -124,7 +124,7 @@ GetVendorByIdStr(const CHAR * Filename, const CHAR * VendorId) if (FileSize < 0) { - ShowMessages("Error: Cannot determine the size of file '%s': error %d\n", Filename, errno); + ShowMessages("err, cannot determine the size of file '%s' (error: 0x%x)\n", Filename, errno); fclose(f); return NULL; } diff --git a/hyperdbg/script-engine/code/common.c b/hyperdbg/script-engine/code/common.c index 173c8b9b..557dbdd3 100644 --- a/hyperdbg/script-engine/code/common.c +++ b/hyperdbg/script-engine/code/common.c @@ -703,17 +703,11 @@ IsOctal(char c) return 0; } -/** - * @brief Allocates a new temporary variable and returns it - * - * @param Error the error type pointer - * @return PSCRIPT_ENGINE_TOKEN - */ PSCRIPT_ENGINE_TOKEN NewTemp(PSCRIPT_ENGINE_ERROR_TYPE Error) { - unsigned int TempID = 0; - int i; + static unsigned int TempID = 0; + int i; for (i = 0; i < MAX_TEMP_COUNT; i++) { if (CurrentUserDefinedFunction->TempMap[i] == 0) @@ -725,42 +719,15 @@ NewTemp(PSCRIPT_ENGINE_ERROR_TYPE Error) } if (i == MAX_TEMP_COUNT) { - // - // No slot is free. The error is reported to the caller, which aborts the - // code generation. A token is still returned so that the (many) call sites - // that dereference the result before testing *Error keep working - // - // TempID is deliberately a plain local rather than a static: when it was - // static it kept the id handed out by the previous call, so an exhausted - // temp list produced a token aliasing a temporary that was still in use - // *Error = SCRIPT_ENGINE_ERROR_TEMP_LIST_FULL; } - PSCRIPT_ENGINE_TOKEN Temp = NewUnknownToken(); - - if (Temp == NULL) - { - // - // There was an error allocating the token, so release the reserved slot - // - if (i != MAX_TEMP_COUNT) - { - CurrentUserDefinedFunction->TempMap[i] = 0; - } - return NULL; - } - - char TempValue[8]; + char TempValue[8]; sprintf(TempValue, "%d", TempID); strcpy(Temp->Value, TempValue); Temp->Type = TEMP; - // - // 'i' is only a valid temporary index when a free slot was actually found, - // otherwise this would size the frame for MAX_TEMP_COUNT + 1 temporaries - // - if (i != MAX_TEMP_COUNT && CurrentUserDefinedFunction->MaxTempNumber < (unsigned long long)(i + 1)) + if (CurrentUserDefinedFunction->MaxTempNumber < (i + 1)) { CurrentUserDefinedFunction->MaxTempNumber = i + 1; }