machinekit-hal icon indicating copy to clipboard operation
machinekit-hal copied to clipboard

xhc-hb04: Invalid read/write of size 8, address is 0 bytes inside a block of size 4 alloc'd

Open ArcEye opened this issue 7 years ago • 2 comments

Issue by rubienr Sun Aug 27 15:37:54 2017 Originally opened as https://github.com/machinekit/machinekit/issues/1254


  • Reason:

Mistakenly allocated sizeof(pointer_type) instead sizeof(type), thus reads/writes of i.e. float which is much latger than poitner type exceed alloce'd block size.

  • Where:

user_comps/xhc-hb04.cc:L471 user_comps/xhc-hb04.cc:L487 user_comps/xhc-hb04.cc:L503

  • Fix:

The line 471 should write return hal_pin_simu(pin_name, ( void**)data_ptr_addr, sizeof(hal_float_t)); instead of return hal_pin_simu(pin_name, ( void**)data_ptr_addr, sizeof(*data_ptr_addr)); Subsequent lines must be fixed respectively.

br, rr

ArcEye avatar Aug 03 '18 15:08 ArcEye

Comment by ArcEye Sun Aug 27 16:01:49 2017


Could you submit a PR please. You may want to do the same to linuxcnc, the code comes directly from there.

ArcEye avatar Aug 03 '18 15:08 ArcEye

Comment by rubienr Sun Aug 27 16:08:03 2017


I'll try my best since I am busy with implementing for the WHB04B-6. For that reason I took the xhc-hb04.cc as baseline and found several issues.

ArcEye avatar Aug 03 '18 15:08 ArcEye