RDKEMW-12350: Fix uninitialized missing error checks in timeZoneDST fallback path#389
Merged
Conversation
yogeswaransky
commented
Jul 6, 2026
Contributor
- Fix zone NULL/uninitialized issues in timezone fallback reader
- 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)
…allback path * Fix zone NULL/uninitialized issues in timezone fallback reader - 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)
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the /opt/persistent/timeZoneDST fallback path in getTimezone() to prevent use of uninitialized data and to add missing error/edge-case handling when reading the timezone file, plus adds unit tests covering the new fallback behavior.
Changes:
- Add
ftell()error/empty/oversize checks andmalloc()NULL handling in thetimeZoneDSTfallback reader. - Tighten parsing to
fscanf(...) == 1, initialize the zone buffer, and only updatezoneValueon non-empty reads. - Add gtest coverage for
timeZoneDSTfallback scenarios (open failure,ftellerror, empty, too large, valid timezone).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
source/xconf-client/xconfclient.c |
Adds defensive size/alloc validation and safer scanning logic for the timeZoneDST fallback. |
source/test/xconf-client/xconfclientTest.cpp |
Adds tests that drive appendRequestParams() through the getTimezone() timeZoneDST fallback path. |
shibu-kv
approved these changes
Jul 6, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.