Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Check for attempts to copy to/from null in cg_memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
ckolivas committed Mar 4, 2015
1 parent 619528d commit 57de2cc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3276,7 +3276,17 @@ void _cg_memcpy(void *dest, const void *src, unsigned int n, const char *file, c
{
if (unlikely(n < 1 || n > (1ul << 31))) {
applog(LOG_ERR, "ERR: Asked to memcpy %u bytes from %s %s():%d",
n, file, func, line);
n, file, func, line);
return;
}
if (unlikely(!dest)) {
applog(LOG_ERR, "ERR: Asked to memcpy %u bytes to NULL from %s %s():%d",
n, file, func, line);
return;
}
if (unlikely(!src)) {
applog(LOG_ERR, "ERR: Asked to memcpy %u bytes from NULL from %s %s():%d",
n, file, func, line);
return;
}
memcpy(dest, src, n);
Expand Down

0 comments on commit 57de2cc

Please sign in to comment.