diff --git a/README.md b/README.md index 0eb1d54..45839f7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This repository provides a CMake-based build project for SLEIGH so that it can b | ---- | ------- | | Linux | Yes | | macOS | Yes | -| Windows | Not yet | +| Windows | Yes | ## Dependencies and Prerequisites diff --git a/patches/HEAD/0005-Use-stroull-instead-of-stroul-to-parse-address-offse.patch b/patches/HEAD/0005-Use-stroull-instead-of-stroul-to-parse-address-offse.patch new file mode 100644 index 0000000..7235f51 --- /dev/null +++ b/patches/HEAD/0005-Use-stroull-instead-of-stroul-to-parse-address-offse.patch @@ -0,0 +1,37 @@ +From 773dda85b84a03c8795e27f1df87e6024bdb208a Mon Sep 17 00:00:00 2001 +From: Alex Cameron +Date: Wed, 3 Aug 2022 20:01:18 +1000 +Subject: [PATCH] Use `stroull` instead of `stroul` to parse address offsets + +--- + Ghidra/Features/Decompiler/src/decompile/cpp/space.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc +index c51e58560..c5cc7541d 100644 +--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc ++++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc +@@ -16,6 +16,8 @@ + #include "space.hh" + #include "translate.hh" + ++#include ++ + AttributeId ATTRIB_BASE = AttributeId("base",89); + AttributeId ATTRIB_DEADCODEDELAY = AttributeId("deadcodedelay",90); + AttributeId ATTRIB_DELAY = AttributeId("delay", 91); +@@ -268,7 +270,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const + } + } + catch(LowlevelError &err) { // Name doesn't exist +- offset = strtoul(s.c_str(),&tmpdata,0); ++ offset = strtoull(s.c_str(),&tmpdata,0); ++ if (offset == ULLONG_MAX) { ++ throw LowlevelError("Offset outside of valid range"); ++ } + offset = addressToByte(offset,wordsize); + enddata = (const char *) tmpdata; + if (enddata - s.c_str() == s.size()) { // If no size or offset override +-- +2.32.1 (Apple Git-133) + diff --git a/patches/stable/0004-Use-stroull-instead-of-stroul-to-parse-address-offse.patch b/patches/stable/0004-Use-stroull-instead-of-stroul-to-parse-address-offse.patch new file mode 100644 index 0000000..b2615ec --- /dev/null +++ b/patches/stable/0004-Use-stroull-instead-of-stroul-to-parse-address-offse.patch @@ -0,0 +1,37 @@ +From b719ae7f3716b303ec0c3d8c79e7d55c7e7cbfdf Mon Sep 17 00:00:00 2001 +From: Alex Cameron +Date: Wed, 3 Aug 2022 20:39:30 +1000 +Subject: [PATCH] Use `stroull` instead of `stroul` to parse address offsets + +--- + Ghidra/Features/Decompiler/src/decompile/cpp/space.cc | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc +index 5f07edf8e..b86c9beae 100644 +--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc ++++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc +@@ -16,6 +16,8 @@ + #include "space.hh" + #include "translate.hh" + ++#include ++ + /// Calculate \e highest based on \e addressSize, and \e wordsize. + /// This also calculates the default pointerLowerBound + void AddrSpace::calcScaleMask(void) +@@ -260,7 +262,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const + } + } + catch(LowlevelError &err) { // Name doesn't exist +- offset = strtoul(s.c_str(),&tmpdata,0); ++ offset = strtoull(s.c_str(),&tmpdata,0); ++ if (offset == ULLONG_MAX) { ++ throw LowlevelError("Offset outside of valid range"); ++ } + offset = addressToByte(offset,wordsize); + enddata = (const char *) tmpdata; + if (enddata - s.c_str() == s.size()) { // If no size or offset override +-- +2.32.1 (Apple Git-133) + diff --git a/src/setup-ghidra-source.cmake b/src/setup-ghidra-source.cmake index 686b4ae..d8c2a69 100644 --- a/src/setup-ghidra-source.cmake +++ b/src/setup-ghidra-source.cmake @@ -21,6 +21,7 @@ set(ghidra_patches "${CMAKE_CURRENT_SOURCE_DIR}/patches/stable/0001-Small-improvements-to-C-decompiler-testing-from-CLI.patch" "${CMAKE_CURRENT_SOURCE_DIR}/patches/stable/0002-Add-include-guards-to-decompiler-C-headers.patch" "${CMAKE_CURRENT_SOURCE_DIR}/patches/stable/0003-Fix-UBSAN-errors-in-decompiler.patch" + "${CMAKE_CURRENT_SOURCE_DIR}/patches/stable/0004-Use-stroull-instead-of-stroul-to-parse-address-offse.patch" ) # Ghidra pinned commits used for pinning last known working HEAD commit @@ -38,6 +39,7 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD") "${CMAKE_CURRENT_SOURCE_DIR}/patches/HEAD/0002-Initialize-ID-lookup-tables-to-fix-sleighexample.patch" "${CMAKE_CURRENT_SOURCE_DIR}/patches/HEAD/0003-Add-include-guards-to-decompiler-C-headers.patch" "${CMAKE_CURRENT_SOURCE_DIR}/patches/HEAD/0004-Fix-UBSAN-errors-in-decompiler.patch" + "${CMAKE_CURRENT_SOURCE_DIR}/patches/HEAD/0005-Use-stroull-instead-of-stroul-to-parse-address-offse.patch" ) string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit) else()