Commit graph

42 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
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
8b6d8181a5 add struct in script engine 2026-07-19 09:39:37 +08:00
sina
eeeff45f70 fix refactoring issues 2026-05-31 16:38:21 +02:00
sina
5fb4c24fe4 refactor doxygen, variables, function names 2 2026-05-31 02:21:47 +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
569881c1c1
refactoring and add function information 2026-02-07 23:33:36 +01: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
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
xmaple555
8799c84345 update token strcture in script-engine 2024-09-27 04:38:23 +08:00
xmaple555
16c60bbe7e add assignment operator in script-engine 2024-08-22 00:30:23 +08:00
xmaple555
b05414a171 update user-defined function for boolean parser 2024-08-21 03:42:03 +08:00
xmaple555
f9ca713601 update script-engine 2 2024-07-25 01:52:58 +08:00
xmaple555
0aba9b5a1b update script-engine 1 2024-07-24 21:25:55 +08:00
xmaple555
36b648eac6 update the user-defined function of the script-engine 2024-07-20 11:58:17 +08:00
SinaKarvandi
7ed7972554 add support for hw_pinX and hw_portX in the script engine 2024-06-21 17:09:41 +09:00
unknown
f5d7332a19 add type of wcsncmp function 2024-06-13 14:42:43 +09:00
Herman Semenov
7bcf1e5c71 fix bitwise extended type, fixed memleaks, remove excess else and cmp int with EOF 2024-04-05 16:13:13 +03:00
Sinaei
cc9aab9ef3 compile script-engine with treat warnings as error 2024-03-18 12:31:11 +09:00
Sinaei
1f7c5ca835 fix script-engine warnings 2024-03-17 20:33:02 +09:00
Sinaei
1dbc3430af fix spelling typos 4 2024-03-17 18:49:51 +09:00
xmaple555
29d79991e4 add user-defined function and variable type in script engine 2024-03-02 01:59:33 +08:00
xmaple555
e6dbc3f49e Add hexadecimal escape sequence as wstring parameter for wstring function in script engine 2023-11-24 04:53:30 +08:00
xmaple555
60fbec6936 Add hexadecimal escape sequence as string parameter for string function in script engine 2023-11-23 01:07:20 +08:00
xmaple555
53805c0ab3 Fix out-of-bound vulnerability in AppendWchar 2023-11-13 03:51:55 +08:00
xmaple555
4e6b3f20dc Correct memcpy and event_inject_error_code to three op and no return value 2023-11-10 00:40:21 +08:00
xmaple555
e3e4095b0b Update wcscat 2023-11-09 00:48:56 +08:00
xmaple555
cb1908d4d0 Update wstring as parameter for wstring functions in script engine 2023-11-09 00:48:26 +08:00
xmaple555
717b369a5c Update string as parameter for string functions in script engine 2023-11-02 23:25:46 +08:00
unknown
01735cfd3e reshaping script side from hv to kd 2023-01-18 20:23:40 +09:00
SinaKarvandi
2a6b7ac4b3 clean codes 2022-05-31 17:09:25 +04:30
mhgholamrezaei
3ab464c117 fix Script Engine bug 2022-05-19 20:16:57 +09:00
SinaKarvandi
831b7e7071 add doxygen headers for script engine 2022-05-18 23:44:03 +04:30
SinaKarvandi
571426e8e9 update script engine doxygens 2022-05-18 18:17:30 +04:30
mhgholamrezaei
e2c3a97e98 cleanup Script Engine 2022-05-18 16:00:16 +09:00
SinaKarvandi
e394346dc1 change script engine directory order 2022-05-10 15:27:06 +04:30
Renamed from hyperdbg/script-engine/common.c (Browse further)