A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/openpgpjs/openpgpjs/commit/b9c597a41a9ad7459d124208ea0ee2ca323e71e3 below:

OP-01-003 Suggested Code Enforcement of RandomBuffer (Low). Clearing … · openpgpjs/openpgpjs@b9c597a · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+8

-5

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+8

-5

lines changed Original file line number Diff line number Diff line change

@@ -164,6 +164,7 @@ RandomBuffer.prototype.set = function(buf) {

164 164

if (buf.length > freeSpace) {

165 165

buf = buf.subarray(0, freeSpace);

166 166

}

167 +

// set buf with offset old size of buffer

167 168

this.buffer.set(buf, this.size);

168 169

this.size += buf.length;

169 170

};

@@ -180,9 +181,11 @@ RandomBuffer.prototype.get = function(buf) {

180 181

throw new Error('Invalid type: buf not an Uint8Array');

181 182

}

182 183

if (this.size < buf.length) {

183 -

throw new Error('Random number buffer depleted.')

184 +

throw new Error('Random number buffer depleted');

184 185

}

185 186

for (var i = 0; i < buf.length; i++) {

186 187

buf[i] = this.buffer[--this.size];

188 +

// clear buffer value

189 +

this.buffer[this.size] = 0;

187 190

}

188 191

};

Original file line number Diff line number Diff line change

@@ -388,7 +388,7 @@ describe('High level API', function() {

388 388

wProxy.encryptMessage([pubKeyRSA], plaintext, function(err, data) {

389 389

expect(data).to.not.exist;

390 390

expect(err).to.exist;

391 -

expect(err).to.eql(new Error('Random number buffer depleted.'));

391 +

expect(err).to.eql(new Error('Random number buffer depleted'));

392 392

done();

393 393

});

394 394

});

@@ -538,16 +538,16 @@ describe('Random Buffer', function() {

538 538

expect(randomBuffer.get.bind(randomBuffer, buf)).to.throw('Invalid type: buf not an Uint8Array');

539 539

buf = new Uint8Array(2);

540 540

randomBuffer.get(buf);

541 -

expect(equal(randomBuffer.buffer, [1,2,5,7,8])).to.be.true;

541 +

expect(equal(randomBuffer.buffer, [1,2,5,0,0])).to.be.true;

542 542

expect(randomBuffer.size).to.equal(3);

543 543

expect(buf).to.to.have.property('0', 8);

544 544

expect(buf).to.to.have.property('1', 7);

545 -

expect(equal(randomBuffer.buffer, [1,2,5,7,8])).to.be.true;

546 545

randomBuffer.get(buf);

547 546

expect(buf).to.to.have.property('0', 5);

548 547

expect(buf).to.to.have.property('1', 2);

548 +

expect(equal(randomBuffer.buffer, [1,0,0,0,0])).to.be.true;

549 549

expect(randomBuffer.size).to.equal(1);

550 -

expect(function() { randomBuffer.get(buf) }).to.throw('Random number buffer depleted.');

550 +

expect(function() { randomBuffer.get(buf) }).to.throw('Random number buffer depleted');

551 551

});

552 552 553 553

});

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4