RDKEMW-12350: Fix uninitialized missing error checks in timeZoneDST fallback path#324
Open
RDKEMW-12350: Fix uninitialized missing error checks in timeZoneDST fallback path#324
Conversation
- Validate ftell return: reject -1 (error) and 0 (empty file) - Add malloc NULL check to prevent NULL pointer dereference - Initialize zone buffer to empty string before fscanf - Reset zone after each iteration to catch stale data - Check fscanf return == 1 instead of != EOF to catch format errors and whitespace-only files - Remove impossible 'zone != NULL' check (zone is stack-local pointer to heap memory, never NULL inside the loop) - Don't reset zoneValue to NULL on empty reads (preserve any previously read valid value) Agent-Logs-Url: https://github.com/rdkcentral/telemetry/sessions/45c3e1dc-dc54-4005-8756-3a32aa7fdeef Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
…d, remove redundant reset Agent-Logs-Url: https://github.com/rdkcentral/telemetry/sessions/45c3e1dc-dc54-4005-8756-3a32aa7fdeef Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
yogeswaransky
April 10, 2026 17:13
View session
Agent-Logs-Url: https://github.com/rdkcentral/telemetry/sessions/0e080027-1be4-41cd-afbc-25283b55d93f Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the timeZoneDST fallback path in getTimezone() so it safely handles unreadable/empty files and allocation failures, aligning with the goal of fixing uninitialized use and missing error checks in that reader.
Changes:
- Add handling for
ftell()failure (numbytes < 0) and for empty files (numbytes == 0) in the/opt/persistent/timeZoneDSTfallback. - Add
mallocfailure handling and initialize thezonebuffer before reading. - Tighten the read loop condition to only process successful
fscanfreads (== 1) and ensure resources are freed/closed on all paths.
yogeswaransky
approved these changes
Apr 13, 2026
Contributor
|
@copilot can you address this comment in a separate PR |
Contributor
Author
|
@yogeswaransky I've opened a new pull request, #329, to work on those changes. Once the pull request is ready, I'll request review from you. |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.