Skip to content

Conversation

Copy link

Copilot AI commented Jan 22, 2026

Addresses feedback on PR #143: the TOCTOU fix correctly eliminated the race condition between stat() and remove(), but silently ignored all remove() failures, potentially hiding legitimate errors like permission denials.

Changes

  • Added errno checking: Modified remove() call to check return value and examine errno
  • Added debug logging:
    • ENOENT → logged as "expected race condition" (file already removed by another thread)
    • Other errors (e.g., EACCES) → logged with errno and strerror() for troubleshooting
  • Added includes: <cerrno> and <cstring> for errno/strerror support

Implementation

// Before
(void)remove(DIRECT_BLOCK_FILENAME);

// After
if (remove(DIRECT_BLOCK_FILENAME) != 0) {
    int err = errno;
    if (err == ENOENT) {
        RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR,"[%s][%d] RFC: %s already removed (expected race condition)\n", ...);
    } else {
        RDK_LOG(RDK_LOG_DEBUG, LOG_RFCMGR,"[%s][%d] RFC: Failed to remove %s, errno=%d (%s)\n", ..., err, strerror(err));
    }
}

Uses DEBUG level to avoid noise in production while maintaining visibility for diagnostics.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 22, 2026 13:17
Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com>
Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com>
Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback from PR #143 Add errno checking and debug logging for remove() failures in TOCTOU fix Jan 22, 2026
Copilot AI requested a review from Vismalskumar0 January 22, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants