Closed tasleson closed 9 months ago
I'm not sure why the code checking requires sizeof(name)
when sizeof
is a unary operator, but I updated that to make the checker happy.
Forgot to mention
ipmi.c: In function 'ipmicmd':
ipmi.c:71:38: error: variable-sized object may not be initialized except with an empty initializer
71 | uint8_t tresp[resplen + 1] = {0};
The other thing that is perhaps not obvious from what I've stated thus far, but when we package things for fedora the packaging specifies addition compiler and linker flags by default which caused the SIGABORT and subsequently found this issue where we are zeroing 1 more byte on the stack than we should be.
The code was using the size of an element + number of elements for the memset which is incorrect. It should be the size of an element * the number of elements. However, as we are simply clearing memory for an array on the stack, a simple sizeof array will give us what we need, which is the number of bytes the array occupies.
This was discovered as a SIGABORT on Fedora 38 testing of pre-released compiled library package.
Note: replaced memsets for structs with struct initialization syntax as requested in review comments.