From 332de7ac7ffea8d733504a13a1df6525b02c7f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Fri, 27 Oct 2023 18:01:29 +0300 Subject: [PATCH 1/3] Fix memload on top of v1.4.81. --- vmhost/contexts/runtime.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vmhost/contexts/runtime.go b/vmhost/contexts/runtime.go index c55e2452..1ec571aa 100644 --- a/vmhost/contexts/runtime.go +++ b/vmhost/contexts/runtime.go @@ -1086,10 +1086,13 @@ func (context *runtimeContext) MemLoad(offset int32, length int32) ([]byte, erro return nil, fmt.Errorf("mem load: %w", vmhost.ErrNegativeLength) } - result := make([]byte, length) + var result []byte + if isRequestedEndTooLarge { + result = make([]byte, memoryLength-uint32(offset)) copy(result, memoryView[offset:]) } else { + result = make([]byte, requestedEnd-offset) copy(result, memoryView[offset:requestedEnd]) } From ae3dd817e0f2932e37b5a6a55d49314d9e6f9f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Fri, 27 Oct 2023 18:44:52 +0300 Subject: [PATCH 2/3] Fix unit test. --- vmhost/contexts/runtime_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmhost/contexts/runtime_test.go b/vmhost/contexts/runtime_test.go index 581c0574..0e48a34b 100644 --- a/vmhost/contexts/runtime_test.go +++ b/vmhost/contexts/runtime_test.go @@ -638,7 +638,7 @@ func TestRuntimeContext_MemLoadCases(t *testing.T) { length = 9 memContents, err = runtimeContext.MemLoad(offset, length) require.Nil(t, err) - require.Equal(t, []byte{'e', 's', 't', ' ', 'd', 'a', 't', 'a', 0}, memContents) + require.Equal(t, []byte{'e', 's', 't', ' ', 'd', 'a', 't', 'a'}, memContents) // Zero length offset = int32(memory.Length() - 8) From 3a213f3a7aafffc4cef079e990fe2ffcfd84adf6 Mon Sep 17 00:00:00 2001 From: jules01 Date: Tue, 31 Oct 2023 12:26:56 +0200 Subject: [PATCH 3/3] - fixed workflows --- .github/workflows/code-coverage.yml | 2 +- .github/workflows/golangci-lint.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 0a097936..ea38e884 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.15.2 + go-version: 1.20.7 id: go - name: Check out code into the Go module directory diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b920f714..611fadc3 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,13 +16,13 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.17.6 + go-version: 1.20.7 - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.45.2 + version: v1.53.2 # Optional: working directory, useful for monorepos # working-directory: somedir