nasa / CF

The Core Flight System (cFS) CFDP application.
Apache License 2.0
76 stars 45 forks source link

CF writes to received SB buffer #420

Open jphickey opened 7 months ago

jphickey commented 7 months ago

Checklist (Please check before submitting)

Describe the bug The output from CFE_SB_ReceiveBuffer() is a pointer to a shared buffer, and thus should be interpreted as const data. The only reason it is not qualified const in the API was due to backward compatibility concerns.

However, CF is actually writing to the buffer in two places.

To Reproduce Send those commands

Expected behavior Should not write to a buffer that was received from SB

Code snips https://github.com/nasa/CF/blob/a0d35e1d7cc822952e18535b195a302a1d59a64c/fsw/src/cf_cmd.c#L147-L149 https://github.com/nasa/CF/blob/a0d35e1d7cc822952e18535b195a302a1d59a64c/fsw/src/cf_cmd.c#L190-L192

System observed on: Inspection

Additional context This is done to ensure null termination of the string. While a valid concern, a function like CFE_SB_MessageStringGet() should be used instead.

Reporter Info Joseph Hickey, Vantage Systems, Inc.