-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check ABI for notifications #2810
Changes from 1 commit
e88062f
f0b3071
c7e9ced
95ee47e
a426a29
e3db758
95b9983
8cb741b
75829a9
080695d
b812394
93b4126
be2ef40
780103a
3f10c96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,17 @@ | |
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Numerics; | ||
using Neo.Cryptography.ECC; | ||
using Neo.IO; | ||
using Neo.Network.P2P.Payloads; | ||
using Neo.SmartContract.Native; | ||
using Neo.VM; | ||
using Neo.VM.Types; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Numerics; | ||
using Array = Neo.VM.Types.Array; | ||
|
||
namespace Neo.SmartContract | ||
|
@@ -428,8 +428,18 @@ private static bool CheckItemType(StackItem item, ContractParameterType type) | |
return aType == StackItemType.Integer; | ||
case ContractParameterType.ByteArray: | ||
case ContractParameterType.String: | ||
return aType is StackItemType.Any or StackItemType.ByteString or StackItemType.Buffer && | ||
Utility.StrictUTF8.GetString(item.GetSpan()) is not null; // Prevent any non-UTF8 string | ||
{ | ||
if (aType is StackItemType.Any or StackItemType.ByteString or StackItemType.Buffer) | ||
Jim8y marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now this check is being performed for both cases when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad :) |
||
try | ||
{ | ||
_ = Utility.StrictUTF8.GetString(item.GetSpan()); // Prevent any non-UTF8 string | ||
return true; | ||
} | ||
catch { } | ||
} | ||
return false; | ||
} | ||
case ContractParameterType.Hash160: | ||
if (aType == StackItemType.Any) return true; | ||
if (aType != StackItemType.ByteString && aType != StackItemType.Buffer) return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to have some additional checks for the
String
type? The way it is now it's absolutely the same asByteArray
, maybe some differentiation can be useful like ifString
could only contain valid UTF-8 byte sequence.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shargon, how about this additional check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnnaShaleva Done