Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #451 #452

Merged
merged 1 commit into from
Sep 22, 2024
Merged

Fix #451 #452

merged 1 commit into from
Sep 22, 2024

Conversation

NQNStudios
Copy link
Collaborator

No description provided.

@CelticMinstrel
Copy link
Member

This isn't really related, but I just realized that the filename += buffer line might be unsafe. I'm not sure if it correctly accounts for the fact that the buffer is known to be 128 characters.

@NQNStudios
Copy link
Collaborator Author

That's here, for conversational reference:

filename += buffer;

Also, is it reading chunks of 128 characters at a time from a command? Why not just read 1 at a time until it reaches the end rather than request more than is known to be there?

@CelticMinstrel
Copy link
Member

I don't really know. I assume that requesting 128 characters when there are only 30 characters is fine though.

@NQNStudios
Copy link
Collaborator Author

So, what would make it safe? Setting the index after the end of the buffer to the zero/null terminator? Constructing a std::string before calling += ?

@CelticMinstrel
Copy link
Member

I was thinking using std::append instead of +=, as there's a form of that which takes a count. But then I looked at the fgets documentation and realized that it actually reads only 127 characters and adds a null terminator, so += seems to be safe after all.

@CelticMinstrel CelticMinstrel merged commit 6f0661e into calref:master Sep 22, 2024
6 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.

2 participants