Commit graph

26 commits

Author SHA1 Message Date
FallinBinary
a78b0208e4 refactor dl, da and dw commands 2026-08-14 08:52:06 -07:00
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
f938929a8c Empty Linux stub for the keystone library 2026-07-24 21:20:44 +02:00
Max Raulea
600eaa47ba update doc and added stub for vendorID pci-id.cpp file, TODO on linux 2026-07-24 21:11:23 +02:00
Max Raulea
4bf987a596 Added missing files to the CMake build file and sweeped them for the Platform functions and guarded windows only code 2026-07-24 21:06:04 +02:00
Max Raulea
38a59b795f Some new lib calls and reverted sleep macro to 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-17 17:54:05 +02:00
sina
16b7f014ce update dl command
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-11 19:59:08 +02:00
sina
5739d0ee4c add PT thread helper 2026-07-03 17:26:01 +02:00
sina
a6421bec2b add module checks based on command requirements 2026-06-08 23:45:43 +02:00
sina
1e49d3f05c refactor doxygen, variables, function names 5 2026-05-31 18:34:03 +02:00
sina
13f2b63053
fix checks for parameters of the XSETBV extension command 2025-08-21 19:48:37 +02:00
sina
5d33cb7395
add function to get syscall number from current system 2025-06-06 21:54:55 +02:00
SinaKarvandi
6005722cc9 Export SDK API for assembling instructions 2024-07-28 18:10:54 +09:00
SinaKarvandi
0001a09190 merge fixes to the assembler parser 2024-07-21 16:42:50 +09:00
SinaKarvandi
5106e440d1 adjust script limitation and VMX-root buffer size constants 2024-07-21 16:35:43 +09:00
Abbas-MG
11d3031c99 BytesCount fixes 2024-07-20 20:47:19 +03:30
SinaKarvandi
9291420cf8 fix minor issues with messages and line counter 2024-07-20 19:02:13 +09:00
SinaKarvandi
8e2491751e return shared buffer on set message callback 2024-07-18 15:59:30 +09:00
Abbas-MG
901e906f54 made assembler a class - add asm to condition and code 2024-07-17 14:12:24 +03:30
SinaKarvandi
5e298a853a export memory reading functions 2024-07-06 22:46:57 +09:00
SinaKarvandi
fb50598525 fix errors of reading memory in debugger mode 2024-07-06 22:02:22 +09:00
SinaKarvandi
556efd2bd3 add a unified memory reading function 2024-07-06 21:16:45 +09:00
SinaKarvandi
4d430f3680 add initial reading memory api 2024-06-26 20:28:56 +09:00
SinaKarvandi
48c362255e build based on new libhyperdbg 2024-06-24 18:05:54 +09:00