goblin icon indicating copy to clipboard operation
goblin copied to clipboard

Fix some offsets computation when using scroll

Open DreydenGys opened this issue 6 months ago • 1 comments

While I was working on a personal project using both goblin and scroll, I found some bugs in the way offset are computed for both DataDirectories and OptionalHeader. Here some minor fixes without breaking changes.

While going through the code I notice that most parsing methods are present twices:

  • one implementation with the scroll traits
  • one using the method parse of each structs

Is there a reason why theses two implementations cohabit? Using only one could reduce bugs and improve maintainability.

DreydenGys avatar Jun 08 '25 16:06 DreydenGys

I noticed that for now, the only reason we rely on the method DataDirectories::parse is that we take the count parameters taken from the optional header. The thing is that no matter what we will construct an array of 16 (NUM_DATA_DIRECTORIES) internally. However as we don't store this count number internally, we will write the 16 entries when using TryIntoCtx. We should either store this count if we know that PE files can have less than 16 entries or consider that it will always be 16 and transform the DataDirectories::Parse implementation a TryFromCtx without the count parameter.

DreydenGys avatar Jun 09 '25 10:06 DreydenGys

CI is failing

m4b avatar Jun 14 '25 08:06 m4b

weird this is nightly failing actually; i didn't think this voted on CI ...

m4b avatar Jun 14 '25 08:06 m4b

can you try applying this patch?

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index badc1bd..11f24f3 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,7 +11,7 @@ jobs:
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
-        build: [MSRV, stable, nightly, macos, win32, win64]
+        build: [MSRV, stable, macos, win32, win64]
         include:
           - build: MSRV # Minimum supported Rust version
             os: ubuntu-latest

to temporarily unblock you

m4b avatar Jun 14 '25 08:06 m4b

NB: non-breaking

m4b avatar Jun 16 '25 04:06 m4b