mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-20 04:20:45 +00:00
13eaba21ef
Using signed integer to represent counts can troube some gcc optimisation passes, for example in https://github.com/fishilico/selinux/runs/2125501324?check_suite_focus=true#step:9:107 In function ‘name_list_to_string’, inlined from ‘constraint_expr_to_string’ at module_to_cil.c:1799:11: module_to_cil.c:1156:8: error: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=] 1156 | str = malloc(len); | ^~~~~~~~~~~ In file included from module_to_cil.c:39: module_to_cil.c: In function ‘constraint_expr_to_string’: /usr/include/stdlib.h:539:14: note: in a call to allocation function ‘malloc’ declared here 539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__ | ^~~~~~ The wide range (from 18446744071562067968 = 0xffffffff80000000 to 18446744073709551615 = 0xffffffffffffffff) was caused by num_names being a signed int used in "len += num_names;", even though it should always be non-negative. Prevent such issues from occurring by using "unsigned int" where appropriate. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org> |
||
---|---|---|
.. | ||
cil | ||
include | ||
man | ||
src | ||
tests | ||
utils | ||
.gitignore | ||
COPYING | ||
Makefile | ||
VERSION |