Commit graph

140 commits

Author SHA1 Message Date
sina
ffbfc0416a Revert NewTemp modifications and adjust error messages
Some checks failed
vs2026-ci / win-amd64-build (debug, x64) (push) Has been cancelled
vs2026-ci / win-amd64-build (release, x64) (push) Has been cancelled
vs2026-ci / Deploy release (push) Has been cancelled
2026-08-02 11:01:19 +02:00
Sina Karvandi
625e75719e
Merge branch 'dev' into claude/code-audit-improvements-prdq23 2026-08-02 10:50:02 +02:00
Claude
1abdde7702
Fix memory-safety and robustness issues in script engine and PCI ID parser
Code audit of the script engine's scanner/token handling and of the PCI ID
database parser. Each of the issues below was reproduced against the current
code before the fix and re-checked afterwards.

script-engine/scanner.c

  * An unterminated string literal ("abc or L"abc) hung the scanner in an
    endless loop: sgetc() returns EOF without consuming input, and neither
    string loop tested for it, so the token grew until allocation failed.
    Both loops now stop at EOF and report the token as UNKNOWN.

script-engine/common.c

  * AppendByte()/AppendWchar() doubled Token->MaxLen before checking whether
    the larger buffer was actually allocated. After a failed allocation MaxLen
    described memory that did not exist and the next append wrote past the end
    of the old buffer. MaxLen is now committed only on success.

  * CopyToken() allocated strlen(Value) + 1 bytes but carried over the source
    token's Len and MaxLen, so the copy's advertised capacity did not match its
    allocation, and WSTRING payloads were truncated at their first embedded
    null byte. The copy is now sized from Len/MaxLen and copied by length, with
    a fallback to the string length for the grammar tokens in parse-table.c,
    which only initialize Type and Value.

  * NewToken() set MaxLen to the value length, which is zero for an empty
    value. The 'Len >= MaxLen - 1' test in the append routines is unsigned, so
    a zero MaxLen wrapped and disabled buffer growth entirely.

  * IsUnderscore() tested 'c >= '_'', which also accepted the backtick, the
    lowercase letters, '{', '|', '}', '~' and DEL. Register scanning uses it,
    so '@rax|1' was lexed as one malformed register name instead of a register,
    an operator and a number. The pseudo-register path already compared against
    '_' directly.

  * NewTokenList() did not check the allocation of its Head buffer.

  * NewTemp() kept the last handed-out id in a static, so an exhausted temp
    list produced a token aliasing a temporary still in use, and it derived
    MaxTempNumber from an out-of-range index. It also dereferenced the new
    token without a null check.

  * FreeTemp() indexed the MAX_TEMP_COUNT-entry map with an unchecked value
    parsed out of the token text.

  * RotateLeftStringOnce() wrote to str[-1] when handed an empty string.

libhyperdbg/debugger/misc/pci-id.cpp

  * The database file was read into a malloc(Length) buffer that was never
    null-terminated, while ReadLine() walks it with strchr(). Looking up an
    absent vendor scans to the end and reads past the allocation.

  * The matched Vendor was allocated with malloc() and its Devices list head
    was only assigned once a device line was parsed, so a vendor with no
    device entries left it uninitialized and FreeVendor() walked a garbage
    pointer.

  * FreeVendor() released the device and subdevice lists but never the Vendor
    itself, leaking one per lookup for every enumerated PCI device.

  * The file handle leaked when the buffer allocation failed, ftell() and
    fread() results were unused, and several error paths leaked the Vendor or
    the not-yet-linked Device/SubDevice.

  * strncmp() compared sizeof(VendorId) bytes, which is the size of the
    pointer rather than the length of a vendor id.

  * ReadLine() passed an unclamped count to strncpy_s(), which triggers the
    invalid parameter handler for a line longer than the destination.

  * GetVendorById() ignored the GetModuleFileName() result and overwrote the
    tail of the path buffer without checking the room left in it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3C1DuhHtqK64eEkHjKCHM
2026-08-01 14:22:52 +00:00
Max Raulea
5175381c73 script engine linux build complete, added undefined references with empty stubs or linux port and updated the Cmake file accordingly 2026-07-24 20:02:00 +02:00
Max Raulea
f5f822a46f Added the hwdbg files to the cmake files and replaced the platform files, RTLzeroMemory 2026-07-24 19:21:06 +02:00
sina
aa96eaa617 fix snprintf_s function
Some checks are pending
vs2026-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2026-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2026-ci / Deploy release (push) Blocked by required conditions
2026-07-23 15:46:03 +02:00
Max Raulea
926070135d Sweeps and extra guards and some new platform functionsd 2026-07-21 15:53:34 +02:00
xmaple555
d44c726dff update variable type and add float type in script enginr 2026-07-20 23:21:34 +08:00
xmaple555
ec5fe7cc8a add float in script engine 2026-07-20 15:03:45 +08:00
xmaple555
9d60a4ddd4 fix handle compound assignment to struct members 2026-07-19 19:53:53 +08:00
xmaple555
2ef2b16ff5 update struct in scrupt engine 2026-07-19 19:22:29 +08:00
xmaple555
8b6d8181a5 add struct in script engine 2026-07-19 09:39:37 +08:00
jtaw5649
f7d196f36d feat(symbols): prefer loaded CodeView PDB identity 2026-06-04 19:15:44 +01:00
maxraulea
d3fe58bcc7 Added extern keyword for globals for linux compilation 2026-06-01 22:44:34 +02:00
maxraulea
2d1293ff51 Add argument to Newtemp for gcc compatibility 2026-06-01 22:34:11 +02:00
sina
eeeff45f70 fix refactoring issues 2026-05-31 16:38:21 +02:00
sina
3bb181fb7d refactor doxygen, variables, function names 2 2026-05-31 03:17:53 +02:00
sina
5fb4c24fe4 refactor doxygen, variables, function names 2 2026-05-31 02:21:47 +02:00
sina
a8f259fbad fix #587 to add functions with no input and return a number 2026-05-25 16:26:26 +02:00
sina
02ab868dc7 add lbr_restore and lbr_restore_by_filter functions
Some checks are pending
vs2022-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2022-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2022-ci / Deploy release (push) Blocked by required conditions
2026-05-24 23:51:12 +02:00
sina
09416e7fe1 add lbrdump command and sdk function 2026-05-04 00:29:54 +02:00
sina
ea74b06286 apply automatic save for printing lbr records
Some checks are pending
vs2022-ci / win-amd64-build (debug, x64) (push) Waiting to run
vs2022-ci / win-amd64-build (release, x64) (push) Waiting to run
vs2022-ci / Deploy release (push) Blocked by required conditions
2026-05-03 01:45:02 +02:00
sina
8b593489e7 change functions of LBR 2026-05-03 01:03:19 +02:00
sina
76d91901cd add lbr_flush function to the script engine 2026-04-26 02:23:04 +02:00
sina
70f6613953 add lbr_save and lbr_dump script engine functions for accessing LBR commands 2026-04-24 20:04:30 +02:00
copilot-swe-agent[bot]
774d61782f
fix: correct typos and one copy-paste error in comments and messages
Agent-Logs-Url: https://github.com/HyperDbg/HyperDbg/sessions/0817c887-8808-4080-a701-6a0211b10595

Co-authored-by: SinaKarvandi <13383992+SinaKarvandi@users.noreply.github.com>
2026-04-23 12:38:48 +00:00
sina
c266a880c3 add lbr start and lbr stop functions to the script engine 2026-04-06 18:33:01 +02:00
sina
569881c1c1
refactoring and add function information 2026-02-07 23:33:36 +01:00
xmaple21215
8bd8950514 add include file in script engine 2026-01-06 16:38:22 +08:00
xmaple555
82540bab5e update array index for boolean expression in script engine 2025-10-26 12:15:41 +08:00
sina
43b0245fa1
fix script variable type 2025-10-21 12:56:21 +02:00
xmaple555
8b4178d416 add array and pointer in script engine 2025-10-21 16:46:49 +08:00
xmaple555
4233ade781 update pointer variable type in script engine 2025-10-15 08:01:17 +08:00
xmaple555
3577876cac fix dd_pa in scrpt-engine 2025-10-14 00:09:58 +08:00
sina
beed7ccc34
fix renaming script engine TOKENs on the auto generated codes 2025-07-07 14:32:43 +02:00
Enzo Berry
6a89a94496 Refactor token structures and related functions in the script engine 2025-07-07 11:46:10 -07:00
unknown
feea1057e2 add microsleep, rdtsc, rdtscp 2025-06-03 10:00:08 +02:00
unknown
0d5ee6ab60 implement microsleep function 2025-06-02 11:26:48 +02:00
sina
6741855d24 add poi_pa hi_pa low_pa db_pa dd_pa dw_pa dq_pa keywords 2025-02-20 15:31:03 +01:00
binophism
f77e99001b Fix: OOB(linear buffer overflow) write fixed 2024-12-25 21:47:29 +03:30
SinaKarvandi
f051c778dc refactor hwdbg buffer interpretation and writing codes 2024-09-27 16:31:29 +02:00
SinaKarvandi
35ca575bfd fix runtime error for deallocating memory from separate DLLs 2024-09-27 14:32:03 +02:00
xmaple555
1df3163ba7 update symbol and token strcture in script-engine 2024-09-27 04:48:43 +08:00
xmaple555
8799c84345 update token strcture in script-engine 2024-09-27 04:38:23 +08:00
SinaKarvandi
f49f92f872 change the showing message function of hardware scripts 2024-09-26 12:53:52 +02:00
SinaKarvandi
1de311647c export ShowMessages to the script engine 2024-09-26 12:44:24 +02:00
SinaKarvandi
f3321dc62d unified script engine imported and exported functions 2024-09-25 16:27:42 +02:00
SinaKarvandi
1ae683af48 add script generation support for stack assignment 2024-09-18 16:53:40 +02:00
xmaple555
211295bf81 update symbol structure and stack buffer in script engine 2024-08-23 22:33:36 +08:00
xmaple555
8edd118a40 update multiple assignment in script engine 2024-08-23 04:10:11 +08:00