-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
memcpy_s()
function got introduced in the C11 standard. TF-A libc provides an implementation of it in file lib/libc/memcpy_s.c
.
This implementation does not fully comply with the C11 standard for the following reasons:
(dsize > ssize)
is allowed by the standard and thus should not be treated as an error. In this case,memcpy_s()
should just copyssize
bytes.
Note that(ssize > dsize)
, on the other hand, is a genuine error case and TF-A code is correct for this one. It matches the following sentence from the C11 standard:
n shall not be greater than s1max
- The following behaviour from the C11 standard is not implemented:
If there is a runtime-constraint violation, the memcpy_s function stores zeros in the first s1max characters of the object pointed to by s1 if s1 is not a null pointer and s1max is not greater than RSIZE_MAX.
- I don't see anything in the C11 standard that forbids
ssize
to be zero. It just would not copy any byte at all but it should not be treated as an error.
Metadata
Metadata
Assignees
Labels
No labels