Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The decoder fails parsing zero-length boxes #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kapetan
Copy link

@kapetan kapetan commented Mar 14, 2016

There is a bug where the decoder halts after encountering a zero-length box.

E.g. calling decode(function(box)) in the handler for the box event, never calls the provided callback if the box has a contentLen of zero. The ignore method is also affected by this.

This pull-request contains a failing test.

A quick solution for only fixing decode would be to add a zero-length check to the Decoder.prototype._buffer method.

Decoder.prototype._buffer = function (size, cb) {
  if (!size) return cb(new Buffer(0))      // This fixes the test. But ignore and stream are still affected.
  this._missing = size
  this._buf = new Buffer(size)
  this._cb = cb
}

I think similar checks could also be added to Decoder.prototype._stream and Decoder.prototype.ignore methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant