Incorrect Handling of HEP3 Chunks ends in Incorrect Payload strings (from Buffer)
haeferer opened this issue · comments
Hi,
first thx for your work in HEP. We tried to use HepOp together with OpenSips, but HepOps fails on Sending our Messages to Postgres.
After going down to the root-problem we found a Problem with Handling of Chunks in HEP-JS:
Lines 385 to 390 in 51b3221
incorrectly implements the length of the chunk (line 390)
Correct would be
var hepParse = new Parser()
.endianess("big")
.uint16("vendor")
.uint16("type")
.uint16("length")
.buffer("chunk", { length: function() {return this.length - 6} }) ; // Vendor Typ and Length are part oft the length
after this change the Patches at
Line 422 in 51b3221
Line 426 in 51b3221
Line 428 in 51b3221
correcting the "too long" chunk must be removed!
The Root cause for our problem was the missing correction (-6) at line
Line 424 in 51b3221
Without the correction the next Vendor ID (0x00) will be part of the string, and this crashes pg-promise during execution of SQL containing 0x00
Thanks for your report and in-depth analysis! Could you submit a PR with your changes for review and integration?
Jup, we will do this tomorrow.
Have a nice Evening,
Cu
Andreas