Skip to content

fix(main): Add warning for log paths that are too long#1481

Merged
tdewey-rpi merged 3 commits into
raspberrypi:mainfrom
Ferdinaelectro1:main
Jan 27, 2026
Merged

fix(main): Add warning for log paths that are too long#1481
tdewey-rpi merged 3 commits into
raspberrypi:mainfrom
Ferdinaelectro1:main

Conversation

@Ferdinaelectro1

Copy link
Copy Markdown
Contributor

Added a warning message when the path provided to --log-file exceeds the buffer size,
informing the user that the path will be truncated to prevent memory corruption.
This helps users notice long paths and avoids potential issues on Linux systems.

Added a warning message when the path provided to --log-file exceeds the buffer size, informing the user that the path will be truncated to prevent memory corruption.
@tdewey-rpi

Copy link
Copy Markdown
Collaborator

Thanks for the submission, @Ferdinaelectro1

Could I suggest a change?

This would be a terminal failure - if a user is explicitly providing a path, with the expectation that the file is written there, the safer route may be to just terminate execution with the error, rather than try to proceed.

@Ferdinaelectro1

Copy link
Copy Markdown
Contributor Author

@tdewey-rpi Thank you for the suggestion, that makes sense.

I agree that if the user explicitly provides a log path, silently truncating it could lead to unexpected behavior.
I will update the change to fail fast with a clear error message instead of proceeding when the path exceeds the buffer size.

Comment thread src/main.cpp
static char logPathBuffer[512];
if(strlen(logPath) + strlen("-elevated") >= sizeof(logPathBuffer)) {
fprintf(stderr, "[ERROR] log path '%s' is too long and cannot be used safely\n", logPath);
return EXIT_FAILURE;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice touch!

@tdewey-rpi tdewey-rpi merged commit d5ae7dd into raspberrypi:main Jan 27, 2026
@tdewey-rpi

Copy link
Copy Markdown
Collaborator

Thanks for responding to the feedback, @Ferdinaelectro1

My pleasure to merge this.

@Ferdinaelectro1

Ferdinaelectro1 commented Jan 27, 2026 via email

Copy link
Copy Markdown
Contributor Author

@Ferdinaelectro1

Ferdinaelectro1 commented Jan 27, 2026 via email

Copy link
Copy Markdown
Contributor Author

@tdewey-rpi

Copy link
Copy Markdown
Collaborator

Thank you so much for merging my PR! I’m really happy to contribute. I would love to continue helping the project. Is there any task, issue, or feature that I could work on next to contribute further?

Fantastic question. Honestly, you know your capabilities better than I do (hardware availability, OS availability, proficiency), so I'd suggest just taking a look at any of the open Issues and having a go.

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