Skip to content

photosyst: fix read uninit dist if bypass fgets() MISRA C:2023 9.1 - #394

Open
GermanAizek wants to merge 1 commit into
Atoptool:masterfrom
GermanAizek:fix-uninit-dist
Open

photosyst: fix read uninit dist if bypass fgets() MISRA C:2023 9.1#394
GermanAizek wants to merge 1 commit into
Atoptool:masterfrom
GermanAizek:fix-uninit-dist

Conversation

@GermanAizek

Copy link
Copy Markdown
Contributor

@Atoptool, for security reasons, I would merge this urgently, there is no CVE ID for this issue yet, I have not checked whether exploitation of the vulnerability is possible.

9.1 The value of an object with an automatic storage time should not be read before it has been set.

Reference: https://www.mathworks.com/help/bugfinder/ref/misrac2023rule9.1.html

9.1 The value of an object with an automatic storage time should not be read before it has been set.

Reference: https://www.mathworks.com/help/bugfinder/ref/misrac2023rule9.1.html
@Atoptool

Atoptool commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Could you please explain what can possibly go wrong since 'nr' is initialized to zero (even when fgets is skipped)?

@GermanAizek

GermanAizek commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Could you please explain what can possibly go wrong since 'nr' is initialized to zero (even when fgets is skipped)?

The initialization of nr to 0 and the subsequent if (nr <= 0) check act as a safeguard, ensuring that the dist array is only accessed and calculations are performed if sscanf successfully parsed at least one integer, setting nr to a positive value.

@Atoptool well, yes, you're right, Clang compiler and static analyzers can unnecessarily incorrectly determine access to an uninitialized memory area.

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