Skip to content

RDKEMW-12350: Fix uninitialized missing error checks in timeZoneDST fallback path#389

Merged
shibu-kv merged 2 commits into
support/1.9from
topic/RDKEMW-12350
Jul 6, 2026
Merged

RDKEMW-12350: Fix uninitialized missing error checks in timeZoneDST fallback path#389
shibu-kv merged 2 commits into
support/1.9from
topic/RDKEMW-12350

Conversation

@yogeswaransky

Copy link
Copy Markdown
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)
Copilot AI review requested due to automatic review settings July 6, 2026 17:39
@yogeswaransky yogeswaransky requested a review from a team as a code owner July 6, 2026 17:39
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 and malloc() NULL handling in the timeZoneDST fallback reader.
  • Tighten parsing to fscanf(...) == 1, initialize the zone buffer, and only update zoneValue on non-empty reads.
  • Add gtest coverage for timeZoneDST fallback scenarios (open failure, ftell error, 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.

Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Copilot AI review requested due to automatic review settings July 6, 2026 17:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
Comment thread source/test/xconf-client/xconfclientTest.cpp
@shibu-kv shibu-kv merged commit e1688e1 into support/1.9 Jul 6, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants