-
Notifications
You must be signed in to change notification settings - Fork 112
fix: Replace strcpy with strlcpy for robustness #1712
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
base: main
Are you sure you want to change the base?
fix: Replace strcpy with strlcpy for robustness #1712
Conversation
498a8e9 to
db9bc33
Compare
db9bc33 to
a11e0e0
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Munkees really loved their string buffers.
Before continuing this change, I think we need another change that gets rid of all the redundant and obsolete buffer copies that I have raised in this review. I don't know if I caught them all, so more reviewing is required.
| */ | ||
| case REG_BINARY: | ||
| strcpy(save_name, "BIN_"); | ||
| strlcpy(save_name, "BIN_", ARRAY_SIZE(save_name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcpy is safe here
| if (pList == NULL) return; | ||
| pList->ResetContent(); | ||
| strcpy(findBuf, dirBuf); | ||
| strlcpy(findBuf, dirBuf, ARRAY_SIZE(findBuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcpy is safe
| if (pList == NULL) return; | ||
| pList->ResetContent(); | ||
| strcpy(findBuf, dirBuf); | ||
| strlcpy(findBuf, dirBuf, ARRAY_SIZE(fileBuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcpy is safe
| continue; | ||
| } | ||
| strcpy(fileBuf, dirBuf); | ||
| strlcpy(fileBuf, dirBuf, ARRAY_SIZE(fileBuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcpy is safe
| dirBuf[len] = 0; | ||
| } | ||
| strcpy(findBuf, dirBuf); | ||
| strlcpy(findBuf, dirBuf, ARRAY_SIZE(findBuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcpy is safe
| AsciiString filename = *it; | ||
| //strcpy(fileBuf, dirBuf); | ||
| strcpy(fileBuf, filename.str()); | ||
| //strlcpy(fileBuf, dirBuf, ARRAY_SIZE(fileBuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just remove this commented code.
a11e0e0 to
cd6da64
Compare
Replacing
strcpyforstrlcpywhere applicableTODO: