NGCP / xbeeplus

Cross-Platform C++11 Xbee Radio API
3 stars 0 forks source link

Risk of buffer overflow in HexString #27

Open maxwey opened 6 years ago

maxwey commented 6 years ago

Received buffer overflow compilation warnings & crashes when running on Ubuntu. Issue identified in the HexString function(s).

The str_buf array size is dependent on the size of argument value; yet the snprintf() function assumes that the str_buf is at least 3 bytes.

See pull request #26

Prior to fix in pull request, program would crash with the following error message:

*** buffer overflow detected ***: /home/maxence/Desktop/missioncontrol/BindingsTestCPP/node_modules/electron/dist/electron --type=renderer --no-sandbox --primordial-pipe-token=40E568901C9A3C3339A28396AF30E003 --lang=en-US --app-path=/home/maxence/Desktop/missioncontrol/BindingsTestCPP --node-integration=true --webview-tag=true --no-sandbox --enable-pinch --num-raster-threads=2 --enable-main-frame-before-activation --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;0,16,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,3553;1,16,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;2,16,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553;3,16,3553;4,0,3553;4,1,3553;4,2,3553;4,3,3553;4,4,3553;4,5,3553;4,6,3553;4,7,3553;4,8,3553;4,9,3553;4,10,3553;4,11,3553;4,12,3553;4,13,3553;4,14,3553;4,15,3553;4,16,3553 --disable-accelerated-video-decode --disable-webrtc-hw-vp8-encoding --service-request-channel-token=40E568901C9A3C3339A28396AF30E003 --renderer-client-id=4 --shared-files=v8_natives_data:100,v8_snapshot_data:101 terminated