OpenCellular icon indicating copy to clipboard operation
OpenCellular copied to clipboard

Bug: Stack smashing error for unit tests on Linux

Open ghost opened this issue 7 years ago • 0 comments

Product: (OC-SDR, OC-LTE, OC-LTE, OC-Power, others)

Unit Tests

Category: (Hardware, Software/stack, Firmware/bootloader, Documentation)

Software/stack

Description

Describe the issue found When running the unit tests on Linux, the result is Couldn't parse test results: ["*** stack smashing detected ***: <unknown> terminated", "Aborted (core dumped)"]

This is caused by the ocmp_ltc4274 test (suites/Test_ocmp_ltc4274.c) Test_ocmp_ltc4274.c, test_get_status(). uint8_t value us passed to the cb_get_status calls, in ocmp_ltc4274.c function uses _get_status which has a (void *) type that is then assigned to uint8_t. This is used for various enum types later in function (ePSEDetection, ePSEClassType, and uint8_t) which, if not using short-enums, the first ePSEDetection will assign an int value to the original uint8_t and overwrite the canary, causing stack-smashing.

Adding -fshort-enums during compilation fixes this, but the incorrect pointers should be fixed as the root cause.

Please provide all necessary steps to reproduce the issue (on Ubuntu) go to the test directory and run make clean test (on Windows cygwin) go to the test directory. Update Makefile to include -fstack-error-all flag and run make clean test **This results in a different stack smashing error, but the same root cause, i.e. uint8_t being used for enums that are int.

ghost avatar Oct 01 '18 23:10 ghost