Skip to content

RDKB-62660: Fix pausing device from Xfinity app is not working#193

Open
veeraputhiran-thangavel wants to merge 1 commit intodevelopfrom
bugfix/RDKB-62660
Open

RDKB-62660: Fix pausing device from Xfinity app is not working#193
veeraputhiran-thangavel wants to merge 1 commit intodevelopfrom
bugfix/RDKB-62660

Conversation

@veeraputhiran-thangavel
Copy link
Contributor

Reason for change:
root@Docsis-Gateway:# cat /tmp/.pcmd
1
08:9d:f4:2d:54:33
root@Docsis-Gateway:
#

When fgets reads the first line "1\n", the newline character is included in the buffer. The strtol function stops parsing at the newline, so endptr points to '\n', not '\0'. Validation check and fails because *endptr != '\0' is true (it's '\n').

Test Procedure:
Login to xfinity app.
Create a profile and assign a device
Pause the assigned device using pause device option

Risks: Low
Signed-off-by:Veeraputhiran_Thangavel@comcast.com

Reason for change:
root@Docsis-Gateway:~# cat /tmp/.pcmd
1
08:9d:f4:2d:54:33
root@Docsis-Gateway:~#

When fgets reads the first line "1\n", the newline character is included in the buffer.
The strtol function stops parsing at the newline, so endptr points to '\n', not '\0'.
Validation check and fails because *endptr != '\0' is true (it's '\n').

Test Procedure:
Login to xfinity app.
Create a profile and assign a device
Pause the assigned device using pause device option

Risks: Low
Signed-off-by:Veeraputhiran_Thangavel@comcast.com
Copilot AI review requested due to automatic review settings January 27, 2026 10:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where pausing a device from the Xfinity app was not working due to incorrect validation of file input. The issue was that fgets includes the newline character in the buffer, but the validation logic only accepted null terminators, causing valid input to fail validation.

Changes:

  • Modified the validation condition in getPcmdList() to accept both '\0' and '\n' as valid string terminators after strtol parsing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

errno = 0;
numDev = strtol(buf, &endptr, 10);
if (endptr == buf || *endptr != '\0' || errno == ERANGE)
if (endptr == buf || (*endptr != '\0' && *endptr != '\n') || errno == ERANGE)
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this fix correctly solves the immediate issue, it deviates from the established pattern in this codebase for handling newlines after fgets. At line 8474, the codebase explicitly strips the newline character after reading with fgets by checking the length and replacing the newline with a null terminator. Consider refactoring to follow this same pattern for consistency: after line 8982, check if the string ends with a newline and replace it with a null terminator before validation. This would make the validation check simpler and more consistent with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link

Copilot AI commented Jan 28, 2026

@veeraputhiran-thangavel I've opened a new pull request, #198, to work on those changes. Once the pull request is ready, I'll request review from you.

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