Abort early on merge() errors
This patch fixes a harmless bug where errors in sorting and clearing obsolete booleans would abort late, and also not print an error message as appropriate. The original intention was immediate abort.
======
Passes tests, I wanted to run it through valgrind, but that never seems to work anymore - valgrind spirals out of control, and eats 70% of my memory whenever I run it. It also still floods the screen with strcpy_chk python warnings, and dlopen ones (translation related). One of these days I'll investigate what those warnings are all about:
--19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18 --19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18 --19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18 --19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18 --19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18 --19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18 --19922-- DWARF2 CFI reader: unhandled CFI instruction 0:18
==20645== Conditional jump or move depends on uninitialised value(s)
==20645== at 0x509FFDC: __strcpy_chk (in /lib64/libc-2.4.so) ==20645== by 0x3883EA8DC5: (within /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883EAB6F7: (within /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883EABBAB: (within /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883EABDB6: PyImport_ImportModuleEx (in /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883E8CA62: (within /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883E364FF: PyObject_Call (in /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883E8FA00: PyEval_CallObjectWithKeywords (in /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883E91713: PyEval_EvalFrame (in /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883E95DD4: PyEval_EvalCodeEx (in /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883E95E21: PyEval_EvalCode (in /usr/lib64/libpython2.4.so.1.0) ==20645== by 0x3883EAA239: PyImport_ExecCodeModuleEx (in /usr/lib64/libpython2.4.so.1.0)
==19922== Conditional jump or move depends on uninitialised value(s)
==19922== at 0x4009F1B: _dl_relocate_object (in /lib64/ld-2.4.so) ==19922== by 0x4003782: dl_main (in /lib64/ld-2.4.so) ==19922== by 0x4012A3A: _dl_sysdep_start (in /lib64/ld-2.4.so) ==19922== by 0x4001384: _dl_start (in /lib64/ld-2.4.so) ==19922== by 0x4000A77: (within /lib64/ld-2.4.so)
==19922== Conditional jump or move depends on uninitialised value(s)
==19922== at 0x400A1A6: _dl_relocate_object (in /lib64/ld-2.4.so) ==19922== by 0x401078D: dl_open_worker (in /lib64/ld-2.4.so) ==19922== by 0x400C875: _dl_catch_error (in /lib64/ld-2.4.so) ==19922== by 0x400FFBB: _dl_open (in /lib64/ld-2.4.so) ==19922== by 0x4FEB1A9: dlopen_doit (in /lib64/libdl-2.4.so) ==19922== by 0x400C875: _dl_catch_error (in /lib64/ld-2.4.so) ==19922== by 0x4FEB71C: _dlerror_run (in /lib64/libdl-2.4.so) ==19922== by 0x4FEB120: dlopen@@GLIBC_2.2.5 (in /lib64/libdl-2.4.so) ==19922== by 0x388050D0A7: init_translations (in /lib64/libselinux.so.1) ==19922== by 0x388050D1B8: init_lib (in /lib64/libselinux.so.1) ==19922== by 0x38805122F1: (within /lib64/libselinux.so.1) ==19922== by 0x3880503B22: (within /lib64/libselinux.so.1)
libsemanage/src/policy_components.c +4 -0
@@ -194,6 +194,10 @@ int semanage_base_merge_components(for (j =0 ; j < nrecords; j++) rtable->free (records[j]);free (records); + +/* Abort on error */ +if (rc <0 ) + goto err; }return rc;