File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -187,28 +187,28 @@ library Base64 {
187
187
// slither-disable-next-line incorrect-shift
188
188
if iszero (and (shl (a, 1 ), 0xffffffd0ffffffc47ff5 )) {
189
189
mstore (0 , errorSelector)
190
- mstore (4 , add (a, 49 ))
190
+ mstore (4 , add (a, 43 ))
191
191
revert (0 , 0x24 )
192
192
}
193
193
let b := sub (byte (29 , input), 43 )
194
194
// slither-disable-next-line incorrect-shift
195
195
if iszero (and (shl (b, 1 ), 0xffffffd0ffffffc47ff5 )) {
196
196
mstore (0 , errorSelector)
197
- mstore (4 , add (b, 49 ))
197
+ mstore (4 , add (b, 43 ))
198
198
revert (0 , 0x24 )
199
199
}
200
200
let c := sub (byte (30 , input), 43 )
201
201
// slither-disable-next-line incorrect-shift
202
202
if iszero (and (shl (c, 1 ), 0xffffffd0ffffffc47ff5 )) {
203
203
mstore (0 , errorSelector)
204
- mstore (4 , add (c, 49 ))
204
+ mstore (4 , add (c, 43 ))
205
205
revert (0 , 0x24 )
206
206
}
207
207
let d := sub (byte (31 , input), 43 )
208
208
// slither-disable-next-line incorrect-shift
209
209
if iszero (and (shl (d, 1 ), 0xffffffd0ffffffc47ff5 )) {
210
210
mstore (0 , errorSelector)
211
- mstore (4 , add (d, 49 ))
211
+ mstore (4 , add (d, 43 ))
212
212
revert (0 , 0x24 )
213
213
}
214
214
Original file line number Diff line number Diff line change @@ -51,12 +51,20 @@ describe('Base64', function () {
51
51
} ) ;
52
52
53
53
it ( 'Decode invalid base64 string' , async function ( ) {
54
+ const helper = { interface : ethers . Interface . from ( [ 'error InvalidBase64Digit(uint8)' ] ) } ;
55
+
54
56
// ord('$') < 43
55
- await expect ( this . mock . $decode ( 'dGVzd$==' ) ) . to . be . reverted ;
57
+ await expect ( this . mock . $decode ( 'dGVzd$==' ) )
58
+ . to . be . revertedWithCustomError ( helper , 'InvalidBase64Digit' )
59
+ . withArgs ( '$' . charCodeAt ( 0 ) ) ;
56
60
// ord('~') > 122
57
- await expect ( this . mock . $decode ( 'dGVzd~==' ) ) . to . be . reverted ;
61
+ await expect ( this . mock . $decode ( 'dGVzd~==' ) )
62
+ . to . be . revertedWithCustomError ( helper , 'InvalidBase64Digit' )
63
+ . withArgs ( '~' . charCodeAt ( 0 ) ) ;
58
64
// ord('@') in range, but '@' not in the dictionary
59
- await expect ( this . mock . $decode ( 'dGVzd@==' ) ) . to . be . reverted ;
65
+ await expect ( this . mock . $decode ( 'dGVzd@==' ) )
66
+ . to . be . revertedWithCustomError ( helper , 'InvalidBase64Digit' )
67
+ . withArgs ( '@' . charCodeAt ( 0 ) ) ;
60
68
} ) ;
61
69
62
70
it ( 'Encode reads beyond the input buffer into dirty memory' , async function ( ) {
You can’t perform that action at this time.
0 commit comments