parent
dc3967ae7b
commit
62ef5a8dc7
2 changed files with 12 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||||
|
@ -206,6 +207,9 @@ func (m *Management) getNefAndManifestFromItems(ic *interop.Context, args []stac
|
||||||
resNef = &nf
|
resNef = &nf
|
||||||
}
|
}
|
||||||
if manifestBytes != nil {
|
if manifestBytes != nil {
|
||||||
|
if !utf8.Valid(manifestBytes) {
|
||||||
|
return nil, nil, errors.New("manifest is not UTF-8 compliant")
|
||||||
|
}
|
||||||
resManifest = new(manifest.Manifest)
|
resManifest = new(manifest.Manifest)
|
||||||
err := json.Unmarshal(manifestBytes, resManifest)
|
err := json.Unmarshal(manifestBytes, resManifest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -177,6 +178,13 @@ func TestContractDeploy(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
checkFAULTState(t, res)
|
checkFAULTState(t, res)
|
||||||
})
|
})
|
||||||
|
t.Run("non-utf8 manifest", func(t *testing.T) {
|
||||||
|
manifB := bytes.Replace(manif1, []byte("TestMain"), []byte("\xff\xfe\xfd"), 1) // Replace name.
|
||||||
|
|
||||||
|
res, err := invokeContractMethod(bc, 11_00000000, mgmtHash, "deploy", nef1b, manifB)
|
||||||
|
require.NoError(t, err)
|
||||||
|
checkFAULTState(t, res)
|
||||||
|
})
|
||||||
t.Run("invalid manifest", func(t *testing.T) {
|
t.Run("invalid manifest", func(t *testing.T) {
|
||||||
pkey, err := keys.NewPrivateKey()
|
pkey, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
Loading…
Reference in a new issue