Commit Graph

4 Commits

Author SHA1 Message Date
Christian Göttsche 8547846ecd semodule_link: avoid NULL dereference on OOM
In case the initial calloc(3) call fails the variable mods is still NULL
while its size hint num_mods is set.

Reported by Clang Analyzer:

    semodule_link.c:182:29: warning: Array access (from variable 'mods') results in a null pointer dereference [core.NullDereference]
      182 |                 sepol_module_package_free(mods[i]);
          |                                           ^~~~~~~

Fixes: 63e798a203 ("semodule_link: update")

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-11-15 08:38:39 -05:00
Christian Göttsche 63e798a203 semodule_link: update
Drop unnecessary declarations.
More verbose error messages and add missing trailing newline.
More strict argument count checking.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are
released in all branches, useful to minimize reports while debugging
libsepol under valgrind(8) or sanitizers.
Add help argument option -h.
Set close-on-exec flag in case of any sibling thread.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-08-04 13:51:50 -04:00
Nicolas Iooss 28a6a560fa semodule-utils: add noreturn attribute to usage()
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-03-07 14:00:39 -05:00
Stephen Smalley c9c97d6e8b Move policycoreutils/semodule_{deps,expand,link} to semodule-utils.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00