question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reading .buffer readUntil: 'eof' returns buffer 1 too short

See original GitHub issue

Thanks for the library, really helpful!

I’ve noticed that parsing rest of message into a buffer, it comes back one too short.

var Parser = require('binary-parser').Parser;
var bp = new Parser().buffer('test',{ readUntil: 'eof'});
var buf=new Buffer([1,2,3]);

console.log(bp.parse(buf));

output:

{ test: <Buffer 01 02> }

I am not an expert but I think that there should not be - 1 on this line :

ctx.pushCode('{0} = buffer.slice(offset, buffer.length - 1);',

https://github.com/keichi/binary-parser/blob/d7d2fd15eff3100af317f4264cd51982c8cc0dc3/lib/binary_parser.js#L442

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
NorthernMan54commented, Nov 18, 2016

Tks for the workaround.

0reactions
keichicommented, Aug 21, 2017

This is now fixed in release 1.1.6 thanks to @kertal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to read until EOF from STDOUT in C? - Stack Overflow
The code in your #4 will only work with very small outputs, since it doesn't start reading until the executed command terminates. That...
Read more >
Read until EOF but not more then N bytes : r/rust - Reddit
In case there are more bytes than N, it must return an error. ... multiple small reads are really done as a large...
Read more >
bufio - Go Packages
Buffered returns the number of bytes that can be read from the current buffer. ... it also returns an error explaining why the...
Read more >
read(2): read from file descriptor - Linux man page - Die.net
read () attempts to read up to count bytes from file descriptor fd into the buffer starting at buf. On files that support...
Read more >
PEP 3116 – New I/O - Python Enhancement Proposals
The raw I/O and buffered I/O layers deal with units of bytes, ... buffered reads will only return a short read if EOF...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found