Skip to content

Commit

Permalink
FIX: checksum port crashes when input is not a series value
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jun 16, 2023
1 parent 68e8afe commit b624280
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/p-checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
}
args = Find_Refines(ds, ALL_WRITE_REFS);
arg = D_ARG(2);
if (!ANY_BINSTR(arg)) Trap_Arg(arg);
REBI64 pos = (REBI64)VAL_INDEX(arg);
if (args & AM_WRITE_SEEK) {
pos += Int64(D_ARG(ARG_WRITE_INDEX));
Expand Down
4 changes: 4 additions & 0 deletions src/tests/units/checksum-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ if find system/catalog/checksums 'ripemd160 [
;opening already opened port restarts computation
--assert sum1 = read write/seek/part open port #{cafe0bad} 2 2
--assert sum1 = read write/seek/part open port tail #{cafe0bad} -2 2

--test-- "checksum port with invalid argument"
;@@ https://github.com/Oldes/Rebol-issues/issues/2553
--assert all [error? e: try [write checksum:md5 1] e/id = 'invalid-arg]
===end-group===

===start-group=== "Checksum HMAC SHA"
Expand Down

0 comments on commit b624280

Please sign in to comment.