Skip to content

Conversation

@BenReed161
Copy link
Collaborator

  • First change in lib/fw.c relates to the summary pointer not being freed after returning from the default case in the switch statement Added a call to free the summary pointer before returning.

  • Second change in cli/main.c changed the 64 byte buffer sent to switchtec_get_fw_version function to 32. Since we are expecting the version information to be at most 32 bytes there is no need to have the destination buffer set to 64 when strncpy is called in the switchtec_get_fw_version function within lib/platform/platform.c.

Copy link
Collaborator

@lsgunth lsgunth left a comment

Choose a reason for hiding this comment

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

Good catch on the missing free(). That's definitely worth while.

I'm not sure the point of reducing the version size at all. Saving a tiny amount of stack memory at the cost of a potential future overflow doesn't really seem worthwhile. At the very least these should have been in two separate patches.

BenReed161 added 2 commits May 1, 2025 13:41
changed the 64 byte buffer sent to switchtec_get_fw_version
function to 32. Since we are expecting the version information
to be at most 32 bytes there is no need to have the destination
buffer set to 64 when strncpy is called in the
switchtec_get_fw_version function within lib/platform/platform.c.
The summary pointer is not being freed after returning from
the default case in the switch statement.
Added a call to free the summary pointer before returning.
@kelvin-cao kelvin-cao merged commit 6f71963 into Microsemi:master May 13, 2025
5 checks passed
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.

3 participants