Function
FwupdPluginmemcpy_safe
Declaration [src]
gboolean
fu_memcpy_safe (
guint8* dst,
gsize dst_sz,
gsize dst_offset,
const guint8* src,
gsize src_sz,
gsize src_offset,
gsize n,
GError** error
)
Description [src]
Copies some memory using memcpy in a safe way. Providing the buffer sizes of both the destination and the source allows us to check for buffer overflow.
Providing the buffer offsets also allows us to check reading past the end of
the source buffer. For this reason the caller should NEVER add an offset to
src
or dst
.
You don’t need to use this function in “obviously correct” cases, nor should you use it when performance is a concern. Only us it when you’re not sure if malicious data from a device or firmware could cause memory corruption.
Available since: | 1.8.2 |
Parameters
dst |
guint8* |
Destination buffer. |
|
The data is owned by the caller of the function. | |
dst_sz |
gsize |
Maximum size of |
|
dst_offset |
gsize |
Offset in bytes into |
|
src |
const guint8* |
Source buffer. |
|
The data is owned by the caller of the function. | |
src_sz |
gsize |
Maximum size of |
|
src_offset |
gsize |
Offset in bytes into |
|
n |
gsize |
Number of bytes to copy from |
|
error |
GError ** |
The return location for a GError* , or NULL . |