mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-17 18:16:52 +00:00
libsepol: do not pass NULL to memcpy
For the first iteration `mod->perm_map[sclassi]` is NULL, thus do not use it as source of a memcpy(3), even with a size of 0. memcpy(3) might be annotated with the function attribute nonnull and UBSan then complains: link.c:193:3: runtime error: null pointer passed as argument 2, which is declared to never be null Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
parent
7f600c40bc
commit
b98d3c4c53
@ -190,8 +190,9 @@ static int permission_copy_callback(hashtab_key_t key, hashtab_datum_t datum,
|
||||
ERR(state->handle, "Out of memory!");
|
||||
return -1;
|
||||
}
|
||||
memcpy(newmap, mod->perm_map[sclassi],
|
||||
mod->perm_map_len[sclassi] * sizeof(*newmap));
|
||||
if (mod->perm_map_len[sclassi] > 0) {
|
||||
memcpy(newmap, mod->perm_map[sclassi], mod->perm_map_len[sclassi] * sizeof(*newmap));
|
||||
}
|
||||
free(mod->perm_map[sclassi]);
|
||||
mod->perm_map[sclassi] = newmap;
|
||||
mod->perm_map_len[sclassi] = perm->s.value;
|
||||
|
Loading…
Reference in New Issue
Block a user