memcpy(x, NULL, 0) is undefined behavior

This commit is contained in:
TuxSH 2018-03-08 11:17:46 +01:00
parent 3d8ff446ad
commit b35c418558
7 changed files with 31 additions and 13 deletions

View file

@ -91,7 +91,9 @@ uint32_t user_get_random_bytes(smc_args_t *args) {
se_generate_random(KEYSLOT_SWITCH_RNGKEY, random_bytes, size);
flush_dcache_range(random_bytes, random_bytes + size);
memcpy(&args->X[1], random_bytes, size);
if (size != 0) {
memcpy(&args->X[1], random_bytes, size);
}
return 0;
}