Skip to content
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

File operations in CFE_ES_ShellOutputCommand() need cleanup #84

Closed
skliper opened this issue Sep 30, 2019 · 6 comments · Fixed by #645 or #692
Closed

File operations in CFE_ES_ShellOutputCommand() need cleanup #84

skliper opened this issue Sep 30, 2019 · 6 comments · Fixed by #645 or #692
Assignees
Labels
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

This function can be simplified and also made more robust.

  • Does unnecessary copying of the input parameters.

  • Does NOT always ensure proper null termination of the inputs. (Copying strings could be justified if it was to ensure null termination of the inputs). The "CFE_ES_ShellCmd" function that is calling this should ensure null termination but it does not.

  • Matching of the "ES" special commands needs improvement - It will not run any OS command that happens to start with "ES_", and it will also not handle it correctly if one happens to be a substring of another but not a complete match.

  • It does not check the return codes from either "OS_read" or "OS_write" calls and assumes they all work perfectly - the correct operation of this function, in fact, does depend on them all working perfectly. In the worst-case scenario, a benign failure of an OS_write() call could have a cascade effect causing a later OS_read() call to block indefinitely.

  • The return value of OS_lseek() is not properly checked. It also relies on having an OS implementation of lseek that can accurately "measure" the size of the file. Not all filesystems/file types are seekable in this nature.

  • It will not work with any "special" file or file system that doesn't support seeking or read/write file handles (such as a pipe).

  • It unnecessarily extends the file on disk to add up to 3 extra spaces, which is only to coax the message generator loop into producing an extra message.

  • Overall, the loop that is generating the telemetry messages can be simplified quite a bit.

  • The fixed 200ms delay between messages should at least be configurable, but there is still no way to tell if buffer overflow is occurring

  • There is no sequence number, and way to tell at the receiving side of one intermediate component message was lost. (Possibly outside the scope of this, and no way to really fix this without changing the binary format of the messages).

@skliper skliper self-assigned this Sep 30, 2019
@skliper skliper added the bug label Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Imported from trac issue 53. Created by jphickey on 2015-05-22T13:39:02, last modified: 2019-03-01T15:27:58

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by jphickey on 2015-05-22 14:02:31:

Need CCB input on how this Shell Command is used in real life missions, and whether these issues are worth pursuing.

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by jphickey on 2015-05-22 14:50:09:

Another possible issue - there is no upper bound on the size of the file that it will attempt to carve up and send as telemetry messages. So if a command produces an unexpectedly large output (just a few kB with the default segment size of 64) this could cause the ES task to spin here for an extremely long period of time.

To give a real example, if the shell command produces a 1MB file, this will take nearly 1 hour to send as 64 byte telemetry chunks, continuously sent at 5 per second, and there is no way to tell it to "stop" since this task is performed by the ES task and therefore blocking it from processing subsequent commands.

@skliper skliper assigned jphickey and unassigned skliper Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Nov 17, 2019

Piling on - CFE_ES_ShellCountObjectCallback looks to be just a copy of CFE_ES_CountObjectCallback. Note ListResources is basically ListResourcesDebug except to a file.

@skliper
Copy link
Contributor Author

skliper commented Feb 26, 2020

Related to #484

@skliper skliper added this to the 6.8.0 milestone Feb 26, 2020
@skliper
Copy link
Contributor Author

skliper commented Apr 27, 2020

#643 - Intent is to add these commands following the typical command processing model, same as the other commands that output to file. No automatic telemetry (never was a requirement) packet. Should resolve all these issues. Old version of the code deprecated per #484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants