Revert NewTemp modifications and adjust error messages

This commit is contained in:
sina 2026-08-02 11:01:19 +02:00
parent 973182ddfe
commit ffbfc0416a
3 changed files with 8 additions and 39 deletions

View file

@ -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))

View file

@ -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;
}

View file

@ -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;
}