-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EVS_GenerateEventTelemetry doesn't handle vsnprintf error cases #1195
Comments
Looking for opinions - could just cast sizeof to (int) which wouldn't do anything (message would still be empty, which is current behavior), could write something unique to message, could do an additional debug event (recursion), could write to the system log... simple "cFE_EVS_SendEvent vsnprintf error %d", or strerror(errno), or explain_vsnprintf(). |
It wouldn't hurt to first test for a negative result before the truncation test at line 417. This way it will be ensured that the truncation test does not implicitly do a sign conversion. As far as what to do -- it really shouldn't fail -- so anything is highly unlikely to occur. Perhaps a WriteToSyslog, but that uses the same function (I think). Just return early and skip the rest maybe? |
Fix #1195, Avoid implicit conversion from vsnprintf errors
Is your feature request related to a problem? Please describe.
vsnprintf can return negative error values, but is compared to unsigned int to handle truncation:
cFE/fsw/cfe-core/src/evs/cfe_evs_utils.c
Lines 414 to 417 in 672b2dc
I wouldn't call this a bug (will just pass the initialized to zero string), but might be worth a unique message?
Describe the solution you'd like
Explicitly handle failure (and cast for comparison)
Describe alternatives you've considered
Place termination character at the start? Any other way to provide clues.
Additional context
Static analysis warning for coercion alters value.
Requester Info
Jacob Hageman - NASA/GSFC
The text was updated successfully, but these errors were encountered: