plcpeople / nodeS7

Node.JS library for communication to Siemens S7 PLCs
MIT License
356 stars 120 forks source link

Handle invalid byteLength in processS7Packet #124

Closed cstim closed 2 years ago

cstim commented 2 years ago

When an item arrives to processS7Packet with a length equal to NaN, probably due to bad input, the library throws a non catchable error. The check added here prevents this catch from occurring by returning before attempting to allocate a Buffer of length NaN

plcpeople commented 2 years ago

Thank you for the PR. I will merge it. Do you know what conditions led to reaching that spot in the code with a byteLength of NaN?

cstim commented 2 years ago

The conditions were not so clear, but we were surely causing a lot of data traffic due to high-load communication. There could be some timeouts from the PLC or similar, or also prematurely ending packets. We were experiencing crashes due to the NaN and got those fixed by this change here, so we did have no need to investigate the cause that led here. Thanks for merging.

Is it also possible to release this as a new version number? Then we wouldn't have to refer to a git commit in order to have this change. Thanks!

plcpeople commented 2 years ago

Done. Thanks.