-
Notifications
You must be signed in to change notification settings - Fork 41
RDKB-62660: Fix pausing device from Xfinity app is not working #193
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
base: develop
Are you sure you want to change the base?
Conversation
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
There was a problem hiding this 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 afterstrtolparsing
💡 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) |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
@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. |
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