-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: Replace device calls to memcpy with tu_memcpy_s #1852
Conversation
25ec4e3
to
326cca5
Compare
Introduces a new function tu_memcpy_s, which is effectively a backport of memcpy_s. The change also refactors calls to memcpy over to the more secure tu_memcpy_s.
326cca5
to
2e47210
Compare
@@ -707,7 +707,7 @@ static int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_ | |||
read_capa10.block_size = tu_htonl(block_size); | |||
|
|||
resplen = sizeof(read_capa10); | |||
memcpy(buffer, &read_capa10, (size_t) resplen); | |||
TU_VERIFY(tu_memcpy_s(buffer, bufsize, &read_capa10, (size_t) resplen)); |
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.
missing ==0 check
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.
superb !! Thank you very much for the PR and sorry again for the delay. memcpy_s is a great idea to prevent memory overflow, this function is new to me. I found an instance where ==0 is not checked, to prevent such as typo, I have change the code to 0==tu_memcpy_s()
, this way it is easier to spot this type of issue.
Thank again for bringing this up.
No worries 👍 |
For UAC class tinyusb/src/class/audio/audio_device.c Line 2293 in 34798ff
I'm in vacation anyone can make a PR ? @silvergasp @hathach |
PR here #1937 |
Describe the PR
Introduces a new function tu_memcpy_s, which is effectively a backport of memcpy_s. The change also refactors calls to memcpy over to the more secure tu_memcpy_s.
More specifically, this change adds some bounds checking to the destination buffer, to prevent buffer overflows.
What this PR cover's;
What this PR doesn't cover;