Socket
Socket
Sign inDemoInstall

smart-buffer

Package Overview
Dependencies
1
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.3 to 3.0.0

21

build/smartbuffer.js

@@ -658,7 +658,17 @@ "use strict";

/**
* Ensures that the internal Buffer is large enough to write data.
*
* @param minLength { Number } The minimum length of the data that needs to be written.
* @param offset { Number } The offset of the data to be written.
*/
* Ensures that the internal Buffer is large enough to read data.
*
* @param length { Number } The length of the data that needs to be read.
*/
ensureReadable(length) {
if (this.remaining() < length) {
throw new Error('Reading beyond the bounds of the data.');
}
}
/**
* Ensures that the internal Buffer is large enough to write data.
*
* @param minLength { Number } The minimum length of the data that needs to be written.
* @param offset { Number } The offset of the data to be written.
*/
ensureWriteable(minLength, offset) {

@@ -701,2 +711,3 @@ const offsetVal = typeof offset === 'number' ? offset : 0;

readNumberValue(func, byteSize) {
this.ensureReadable(byteSize);
// Call Buffer.readXXXX();

@@ -703,0 +714,0 @@ const value = func.call(this.buff, this.readOffset);

# Change Log
## 3.0
> Released 02/12/2017
### Bug Fixes
* readUIntXXXX() methods will now throw an exception if they attempt to read beyond the bounds of the valid buffer data available.
* **Note** This is technically a breaking change, so version is bumped to 3.x.
## 2.0

@@ -4,0 +11,0 @@ > Relased 01/30/2017

{
"name": "smart-buffer",
"version": "2.0.3",
"version": "3.0.0",
"description": "A smarter Buffer that keeps track of its own read and write positions while growing endlessly.",

@@ -5,0 +5,0 @@ "main": "build/smartbuffer.js",

@@ -31,2 +31,5 @@ smart-buffer [![Build Status](https://travis-ci.org/JoshGlazebrook/smart-buffer.svg?branch=master)](https://travis-ci.org/JoshGlazebrook/smart-buffer) [![Coverage Status](https://coveralls.io/repos/github/JoshGlazebrook/smart-buffer/badge.svg?branch=master)](https://coveralls.io/github/JoshGlazebrook/smart-buffer?branch=master)

## Breaking Changes with 3.0
Starting with 3.0, if any of the readIntXXXX() methods are called and the requested data is larger than the bounds of the internally managed valid buffer data, an exception will now be thrown.
## Installing:

@@ -56,8 +59,14 @@

```javascript
// 1.x
// 1.x (javascript)
var SmartBuffer = require('smart-buffer');
// 2.x
// 1.x (typescript)
import SmartBuffer = require('smart-buffer');
// 2.x+ (javascript)
const SmartBuffer = require('smart-buffer').SmartBuffer;
// 2.x+ (typescript)
import { SmartBuffer, SmartBufferOptions} from 'smart-buffer';
function createLoginPacket(username, password, age, country) {

@@ -64,0 +73,0 @@ let packet = new SmartBuffer();

@@ -214,4 +214,13 @@ var SmartBuffer = require('../build/smartbuffer').SmartBuffer;

it('should throw an exception if attempting to read numeric values from a buffer with not enough data left', function() {
assert.throws(function() {
reader.readUInt32BE();
});
});
});
describe('Basic String Values', function () {

@@ -218,0 +227,0 @@ var reader = new SmartBuffer();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc