Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
const { expect } = require('chai');
|
||||
|
||||
const Base64 = artifacts.require('$Base64');
|
||||
const Base64Dirty = artifacts.require('$Base64Dirty');
|
||||
|
||||
contract('Strings', function () {
|
||||
contract('Base64', function () {
|
||||
beforeEach(async function () {
|
||||
this.base64 = await Base64.new();
|
||||
});
|
||||
@ -30,4 +31,13 @@ contract('Strings', function () {
|
||||
expect(await this.base64.$encode([])).to.equal('');
|
||||
});
|
||||
});
|
||||
|
||||
it('Encode reads beyond the input buffer into dirty memory', async function () {
|
||||
const mock = await Base64Dirty.new();
|
||||
const buffer32 = Buffer.from(web3.utils.soliditySha3('example').replace(/0x/, ''), 'hex');
|
||||
const buffer31 = buffer32.slice(0, -2);
|
||||
|
||||
expect(await mock.encode(buffer31)).to.equal(buffer31.toString('base64'));
|
||||
expect(await mock.encode(buffer32)).to.equal(buffer32.toString('base64'));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user