CF updates its destination file "in-place"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c
- Domain
- networking
Research direction
Start by tracing the CF receive path that opens the destination named in the Metadata PDU, then review the corner-case handling discussed in issue #131. The change is complete when incoming data is written to a temporary file and the original destination is replaced only after final CRC and size validation succeeds.
Written by the indexing model from the issue text.
Description
The CF application, when receiving files, will open the destination file as indicated in the Metadata PDU and immediately start writing data to it, thereby overwriting any data that was previously in the file at that position.
This can be dangerous, because the file transfer may not ultimately succeed. For instance, CRC errors may occur, or part of the transfer might get lost. But once data has been clobbered, there is no way to "undo" and restore the original data -- its gone. So now the user has a situation where neither the new file nor the original file are valid - the file is just corrupt now.
It is often desirable to write data to a temporary file first, let the transfer run to completion (storing ALL data in the temporary file), and then rename the file to its final/correct filename only after the final CRC and size checks have passed and the data is known to be good (or at least to the extent that CF can verify it).
In fact, this is the only way to safely update application binary object (.so files) on many targets, since the text/rodata memory pages may be mmap'ed directly to the file on disk. If these are updated in place, and the file is an actively-running application, then the running code will immediately "see" the modifications, and likely crash/segfault depending on what it was doing at the time.
Recommendation here is to ALWAYS use a temporary file to store incoming data, never overwrite existing files until final validations have occurred. This will also avoid some of the special logic that only handled corner cases (see issue #131) by making that more the norm than the exception.
- Dominant language
- C
- Stars
- 123
- Forks
- 82
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nasa/CF
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Assert checks non-existent variable (`pt`) in `CF_CFDP_ProcessPlaybackDirectory()`May be free again A pull request for this issue was closed without being merged. Openinvalid
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Similar issues
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
389ds/389-ds-base#8251 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ROCm/hrx-system#3628 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
OpenPrinting/cups#1844 ·
Maintainers usually reply within 1 day