Fixed findings

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-401): [#def1]
libselinux-3.10/src/label_media.c:138:28: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)*data.nspec, 80)’
libselinux-3.10/src/label_media.c:70:12: enter_function: entry to ‘init’
libselinux-3.10/src/label_media.c:100:12: branch_true: following ‘true’ branch (when ‘path’ is NULL)...
libselinux-3.10/src/label_media.c:101:24: branch_true: ...to here
libselinux-3.10/src/label_media.c:102:12: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_media.c:104:9: branch_false: ...to here
libselinux-3.10/src/label_media.c:106:12: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_media.c:108:14: branch_false: ...to here
libselinux-3.10/src/label_media.c:108:12: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_media.c:112:26: branch_false: ...to here
libselinux-3.10/src/label_media.c:123:24: branch_true: following ‘true’ branch (when ‘pass != 2’)...
libselinux-3.10/src/label_media.c:125:17: branch_true: ...to here
libselinux-3.10/src/label_media.c:126:24: branch_true: following ‘true’ branch...
libselinux-3.10/src/label_media.c:127:24: branch_true: ...to here
libselinux-3.10/src/label_media.c:126:24: branch_true: following ‘true’ branch...
libselinux-3.10/src/label_media.c:128:28: branch_true: ...to here
libselinux-3.10/src/label_media.c:128:29: call_function: calling ‘process_line’ from ‘init’
libselinux-3.10/src/label_media.c:128:29: return_function: returning to ‘init’ from ‘process_line’
libselinux-3.10/src/label_media.c:126:24: branch_true: following ‘true’ branch...
libselinux-3.10/src/label_media.c:127:24: branch_true: ...to here
libselinux-3.10/src/label_media.c:126:24: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_media.c:132:20: branch_false: ...to here
libselinux-3.10/src/label_media.c:132:20: branch_true: following ‘true’ branch (when ‘pass == 0’)...
libselinux-3.10/src/label_media.c:133:29: branch_true: ...to here
libselinux-3.10/src/label_media.c:133:28: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_media.c:137:42: branch_false: ...to here
libselinux-3.10/src/label_media.c:137:42: acquire_memory: allocated here
libselinux-3.10/src/label_media.c:138:28: danger: ‘calloc((long unsigned int)*data.nspec, 80)’ leaks here; was allocated at [(31)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/30)
#  136|   			}
#  137|   			data->spec_arr = calloc(data->nspec, sizeof(spec_t));
#  138|-> 			if (data->spec_arr == NULL)
#  139|   				goto finish;
#  140|   			maxnspec = data->nspec;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def2]
libselinux-3.10/src/label_x.c:165:28: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc((long unsigned int)*data.nspec, 80)’
libselinux-3.10/src/label_x.c:97:12: enter_function: entry to ‘init’
libselinux-3.10/src/label_x.c:127:12: branch_true: following ‘true’ branch (when ‘path’ is NULL)...
libselinux-3.10/src/label_x.c:128:24: branch_true: ...to here
libselinux-3.10/src/label_x.c:129:12: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_x.c:131:9: branch_false: ...to here
libselinux-3.10/src/label_x.c:133:12: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_x.c:135:14: branch_false: ...to here
libselinux-3.10/src/label_x.c:135:12: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_x.c:139:26: branch_false: ...to here
libselinux-3.10/src/label_x.c:150:24: branch_true: following ‘true’ branch (when ‘pass != 2’)...
libselinux-3.10/src/label_x.c:152:17: branch_true: ...to here
libselinux-3.10/src/label_x.c:153:24: branch_true: following ‘true’ branch...
libselinux-3.10/src/label_x.c:154:24: branch_true: ...to here
libselinux-3.10/src/label_x.c:153:24: branch_true: following ‘true’ branch...
libselinux-3.10/src/label_x.c:155:28: branch_true: ...to here
libselinux-3.10/src/label_x.c:155:29: call_function: calling ‘process_line’ from ‘init’
libselinux-3.10/src/label_x.c:155:29: return_function: returning to ‘init’ from ‘process_line’
libselinux-3.10/src/label_x.c:153:24: branch_true: following ‘true’ branch...
libselinux-3.10/src/label_x.c:154:24: branch_true: ...to here
libselinux-3.10/src/label_x.c:153:24: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_x.c:159:20: branch_false: ...to here
libselinux-3.10/src/label_x.c:159:20: branch_true: following ‘true’ branch (when ‘pass == 0’)...
libselinux-3.10/src/label_x.c:160:29: branch_true: ...to here
libselinux-3.10/src/label_x.c:160:28: branch_false: following ‘false’ branch...
libselinux-3.10/src/label_x.c:164:42: branch_false: ...to here
libselinux-3.10/src/label_x.c:164:42: acquire_memory: allocated here
libselinux-3.10/src/label_x.c:165:28: danger: ‘calloc((long unsigned int)*data.nspec, 80)’ leaks here; was allocated at [(31)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/30)
#  163|   			}
#  164|   			data->spec_arr = calloc(data->nspec, sizeof(spec_t));
#  165|-> 			if (data->spec_arr == NULL)
#  166|   				goto finish;
#  167|   			maxnspec = data->nspec;

Error: COMPILER_WARNING (CWE-704): [#def3]
libselinux-3.10/src/selinux_config.c: scope_hint: In function ‘selinux_set_policy_root’
libselinux-3.10/src/selinux_config.c:284:29: warning[-Wdiscarded-qualifiers]: initialization discards ‘const’ qualifier from pointer target type
#  284 |         char *policy_type = strrchr(path, '/');
#      |                             ^~~~~~~
#  282|   {
#  283|   	int i;
#  284|-> 	char *policy_type = strrchr(path, '/');
#  285|   	if (!policy_type) {
#  286|   		errno = EINVAL;

Error: COMPILER_WARNING (CWE-704): [#def4]
libselinux-3.10/src/selinux_config.c:284:29: warning[-Wdiscarded-qualifiers]: initialization discards ‘const’ qualifier from pointer target type
#  282|   {
#  283|   	int i;
#  284|-> 	char *policy_type = strrchr(path, '/');
#  285|   	if (!policy_type) {
#  286|   		errno = EINVAL;

Error: GCC_ANALYZER_WARNING (CWE-415): [#def5]
libselinux-3.10/src/selinux_restorecon.c:183:20: warning[-Wanalyzer-double-free]: double-‘reallocarray’ of ‘exclude_lst’
libselinux-3.10/src/selinux_restorecon.c:1475:6: enter_function: entry to ‘selinux_restorecon_set_exclude_list’
libselinux-3.10/src/selinux_restorecon.c:1480:21: branch_true: following ‘true’ branch...
libselinux-3.10/src/selinux_restorecon.c:1481:21: branch_true: ...to here
libselinux-3.10/src/selinux_restorecon.c:1481:20: branch_true: following ‘true’ branch...
libselinux-3.10/src/selinux_restorecon.c:1481:56: branch_true: ...to here
libselinux-3.10/src/selinux_restorecon.c:1481:21: branch_false: following ‘false’ branch...
libselinux-3.10/src/selinux_restorecon.c:1487:21: branch_false: ...to here
libselinux-3.10/src/selinux_restorecon.c:1487:21: call_function: calling ‘add_exclude’ from ‘selinux_restorecon_set_exclude_list’
libselinux-3.10/src/selinux_restorecon.c:1487:21: return_function: returning to ‘selinux_restorecon_set_exclude_list’ from ‘add_exclude’
libselinux-3.10/src/selinux_restorecon.c:1487:20: branch_true: following ‘true’ branch...
libselinux-3.10/src/selinux_restorecon.c:1488:21: branch_true: ...to here
libselinux-3.10/src/selinux_restorecon.c:1487:21: branch_false: following ‘false’ branch...
libselinux-3.10/src/selinux_restorecon.c:1480:38: branch_false: ...to here
libselinux-3.10/src/selinux_restorecon.c:1480:21: branch_true: following ‘true’ branch...
libselinux-3.10/src/selinux_restorecon.c:1481:21: branch_true: ...to here
libselinux-3.10/src/selinux_restorecon.c:1481:20: branch_true: following ‘true’ branch...
libselinux-3.10/src/selinux_restorecon.c:1481:56: branch_true: ...to here
libselinux-3.10/src/selinux_restorecon.c:1481:21: branch_false: following ‘false’ branch...
libselinux-3.10/src/selinux_restorecon.c:1487:21: branch_false: ...to here
libselinux-3.10/src/selinux_restorecon.c:1487:21: call_function: calling ‘add_exclude’ from ‘selinux_restorecon_set_exclude_list’
#  181|   	}
#  182|   
#  183|-> 	tmp_list = reallocarray(exclude_lst, exclude_count + 1, sizeof(struct edir));
#  184|   	if (!tmp_list)
#  185|   		goto oom;

Scan Properties

analyzer-version-clippy1.97.1
analyzer-version-cppcheck2.21.1
analyzer-version-gcc16.1.1
analyzer-version-gcc-analyzer16.1.1
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
diffbase-analyzer-version-clippy1.97.1
diffbase-analyzer-version-cppcheck2.21.1
diffbase-analyzer-version-gcc16.1.1
diffbase-analyzer-version-gcc-analyzer16.1.1
diffbase-analyzer-version-shellcheck0.11.0
diffbase-analyzer-version-unicontrol0.0.2
diffbase-enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
diffbase-exit-code0
diffbase-hostip-172-16-1-56.us-west-2.compute.internal
diffbase-known-false-positives/usr/share/csmock/known-false-positives.js
diffbase-known-false-positives-rpmknown-false-positives-0.0.0.20260524.213755.g3c6d0be.main-1.el9.noarch
diffbase-mock-configfedora-rawhide-x86_64
diffbase-project-namelibselinux-3.11-3.fc45
diffbase-store-results-to/tmp/tmpaw8sce34/libselinux-3.11-3.fc45.tar.xz
diffbase-time-created2026-08-03 17:53:46
diffbase-time-finished2026-08-03 17:55:37
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,clippy,unicontrol,shellcheck,cppcheck' '-o' '/tmp/tmpaw8sce34/libselinux-3.11-3.fc45.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpaw8sce34/libselinux-3.11-3.fc45.src.rpm'
diffbase-tool-versioncsmock-3.8.7.20260803.142340.gb75b18e-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-56.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20260524.213755.g3c6d0be.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-namelibselinux-3.10-1.fc44
store-results-to/tmp/tmpmr_ao70w/libselinux-3.10-1.fc44.tar.xz
time-created2026-08-03 17:50:41
time-finished2026-08-03 17:53:21
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,clippy,unicontrol,shellcheck,cppcheck' '-o' '/tmp/tmpmr_ao70w/libselinux-3.10-1.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpmr_ao70w/libselinux-3.10-1.fc44.src.rpm'
tool-versioncsmock-3.8.7.20260803.142340.gb75b18e-1.el9