Fixed findings

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-775): [#def1]
LVM2.2.03.34/lib/device/persist.c:176:17: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(&path, "r")’
LVM2.2.03.34/lib/device/persist.c:164:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:167:20: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:167:20: acquire_resource: opened here
LVM2.2.03.34/lib/device/persist.c:167:12: branch_false: following ‘false’ branch...
 branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:172:16: branch_true: following ‘true’ branch...
LVM2.2.03.34/lib/device/persist.c:173:21: branch_true: ...to here
LVM2.2.03.34/lib/device/persist.c:176:17: danger: ‘fopen(&path, "r")’ leaks here; was opened at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#  174|   			continue;
#  175|   
#  176|-> 		dm_strncpy(buf_key, line, sizeof(buf_key));
#  177|   		break;
#  178|   	}

Error: GCC_ANALYZER_WARNING (CWE-401): [#def2]
LVM2.2.03.34/lib/device/persist.c:176:17: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(&path, "r")’
LVM2.2.03.34/lib/device/persist.c:164:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:167:20: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:167:20: acquire_memory: allocated here
LVM2.2.03.34/lib/device/persist.c:167:12: branch_false: following ‘false’ branch...
 branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:172:16: branch_true: following ‘true’ branch...
LVM2.2.03.34/lib/device/persist.c:173:21: branch_true: ...to here
LVM2.2.03.34/lib/device/persist.c:176:17: danger: ‘fopen(&path, "r")’ leaks here; was allocated at [(3)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/2)
#  174|   			continue;
#  175|   
#  176|-> 		dm_strncpy(buf_key, line, sizeof(buf_key));
#  177|   		break;
#  178|   	}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def3]
LVM2.2.03.34/lib/device/persist.c:241:13: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(&path, "w")’
LVM2.2.03.34/lib/device/persist.c:231:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:234:20: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:234:20: acquire_resource: opened here
LVM2.2.03.34/lib/device/persist.c:234:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:239:9: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:241:13: danger: ‘fopen(&path, "w")’ leaks here; was opened at [(3)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/2)
#  239|   	fprintf(fp, "0x%llx\n", (unsigned long long)key);
#  240|   
#  241|-> 	if (fflush(fp))
#  242|   		log_debug("Failed to write/flush key file");
#  243|   	if (fclose(fp))

Error: GCC_ANALYZER_WARNING (CWE-401): [#def4]
LVM2.2.03.34/lib/device/persist.c:241:13: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(&path, "w")’
LVM2.2.03.34/lib/device/persist.c:231:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:234:20: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:234:20: acquire_memory: allocated here
LVM2.2.03.34/lib/device/persist.c:234:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:239:9: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:241:13: danger: ‘fopen(&path, "w")’ leaks here; was allocated at [(3)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/2)
#  239|   	fprintf(fp, "0x%llx\n", (unsigned long long)key);
#  240|   
#  241|-> 	if (fflush(fp))
#  242|   		log_debug("Failed to write/flush key file");
#  243|   	if (fclose(fp))

Error: GCC_ANALYZER_WARNING (CWE-775): [#def5]
LVM2.2.03.34/lib/device/persist.c:242:17: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(&path, "w")’
LVM2.2.03.34/lib/device/persist.c:231:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:234:20: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:234:20: acquire_resource: opened here
LVM2.2.03.34/lib/device/persist.c:234:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:239:9: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:241:12: branch_true: following ‘true’ branch...
LVM2.2.03.34/lib/device/persist.c:242:17: branch_true: ...to here
LVM2.2.03.34/lib/device/persist.c:242:17: danger: ‘fopen(&path, "w")’ leaks here; was opened at [(3)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/2)
#  240|   
#  241|   	if (fflush(fp))
#  242|-> 		log_debug("Failed to write/flush key file");
#  243|   	if (fclose(fp))
#  244|   		log_debug("Failed to write/close key file");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
LVM2.2.03.34/lib/device/persist.c:242:17: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(&path, "w")’
LVM2.2.03.34/lib/device/persist.c:231:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:234:20: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:234:20: acquire_memory: allocated here
LVM2.2.03.34/lib/device/persist.c:234:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/lib/device/persist.c:239:9: branch_false: ...to here
LVM2.2.03.34/lib/device/persist.c:241:12: branch_true: following ‘true’ branch...
LVM2.2.03.34/lib/device/persist.c:242:17: branch_true: ...to here
LVM2.2.03.34/lib/device/persist.c:242:17: danger: ‘fopen(&path, "w")’ leaks here; was allocated at [(3)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/2)
#  240|   
#  241|   	if (fflush(fp))
#  242|-> 		log_debug("Failed to write/flush key file");
#  243|   	if (fclose(fp))
#  244|   		log_debug("Failed to write/close key file");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def7]
LVM2.2.03.34/lib/raid/raid.c:722:21: warning[-Wanalyzer-malloc-leak]: leak of ‘_init_raid_segtype(cmd, & _raid_types[i], get_monitor_dso_path(cmd, 284), monitored)’
LVM2.2.03.34/lib/raid/raid.c:699:5: enter_function: entry to ‘init_raid_segtypes’
LVM2.2.03.34/lib/raid/raid.c:721:21: branch_true: following ‘true’ branch (when ‘i != 21’)...
LVM2.2.03.34/lib/raid/raid.c:722:32: branch_true: ...to here
LVM2.2.03.34/lib/raid/raid.c:722:32: call_function: calling ‘_init_raid_segtype’ from ‘init_raid_segtypes’
LVM2.2.03.34/lib/raid/raid.c:722:32: return_function: returning to ‘init_raid_segtypes’ from ‘_init_raid_segtype’
LVM2.2.03.34/lib/raid/raid.c:722:20: branch_true: following ‘true’ branch...
LVM2.2.03.34/lib/raid/raid.c:723:22: branch_true: ...to here
LVM2.2.03.34/lib/raid/raid.c:722:21: danger: ‘_init_raid_segtype(cmd, & _raid_types[i], get_monitor_dso_path(cmd, 284), monitored)’ leaks here; was allocated at [(7)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/6)
#  720|   
#  721|   	for (i = 0; i < DM_ARRAY_SIZE(_raid_types); ++i)
#  722|-> 		if ((segtype = _init_raid_segtype(cmd, &_raid_types[i], dso, monitored)) &&
#  723|   		    !lvm_register_segtype(seglib, segtype)) {
#  724|   			/* segtype is already destroyed */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def8]
LVM2.2.03.34/tools/pvck.c:968:33: warning[-Wanalyzer-malloc-leak]: leak of ‘calloc(1, meta_size + 1)’
LVM2.2.03.34/tools/pvck.c:885:12: enter_function: entry to ‘_dump_current_text’
LVM2.2.03.34/tools/pvck.c:901:26: call_function: inlined call to ‘zalloc’ from ‘_dump_current_text’
LVM2.2.03.34/tools/pvck.c:901:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:915:13: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:939:22: call_function: calling ‘_read_bytes’ from ‘_dump_current_text’
LVM2.2.03.34/tools/pvck.c:939:22: return_function: returning to ‘_dump_current_text’ from ‘_read_bytes’
LVM2.2.03.34/tools/pvck.c:939:20: branch_true: following ‘true’ branch...
LVM2.2.03.34/tools/pvck.c:947:17: branch_true: ...to here
LVM2.2.03.34/tools/pvck.c:955:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:959:22: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:959:20: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:965:29: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:965:28: branch_true: following ‘true’ branch...
LVM2.2.03.34/tools/pvck.c:965:42: branch_true: ...to here
LVM2.2.03.34/tools/pvck.c:965:29: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:967:28: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:967:28: branch_true: following ‘true’ branch...
LVM2.2.03.34/tools/pvck.c:968:33: danger: ‘calloc(1, meta_size + 1)’ leaks here; was allocated at [(3)](sarif:/runs/0/results/26/codeFlows/0/threadFlows/0/locations/2)
#  966|   				vgname = strdup(cft->root->key);
#  967|   			if (cft->root && cft->root->child)
#  968|-> 				dm_config_get_uint32(cft->root->child, "seqno", &seqno);
#  969|   		}
#  970|   		config_destroy(cft);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def9]
LVM2.2.03.34/tools/pvck.c:968:33: warning[-Wanalyzer-malloc-leak]: leak of ‘vgname’
LVM2.2.03.34/tools/pvck.c:885:12: enter_function: entry to ‘_dump_current_text’
LVM2.2.03.34/tools/pvck.c:901:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:915:13: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:939:22: call_function: calling ‘_read_bytes’ from ‘_dump_current_text’
LVM2.2.03.34/tools/pvck.c:939:22: return_function: returning to ‘_dump_current_text’ from ‘_read_bytes’
LVM2.2.03.34/tools/pvck.c:939:20: branch_true: following ‘true’ branch...
LVM2.2.03.34/tools/pvck.c:947:17: branch_true: ...to here
LVM2.2.03.34/tools/pvck.c:955:12: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:959:22: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:959:20: branch_false: following ‘false’ branch...
LVM2.2.03.34/tools/pvck.c:965:29: branch_false: ...to here
LVM2.2.03.34/tools/pvck.c:965:28: branch_true: following ‘true’ branch...
LVM2.2.03.34/tools/pvck.c:966:42: acquire_memory: allocated here
LVM2.2.03.34/tools/pvck.c:967:28: branch_true: following ‘true’ branch...
LVM2.2.03.34/tools/pvck.c:968:33: danger: ‘vgname’ leaks here; was allocated at [(17)](sarif:/runs/0/results/25/codeFlows/0/threadFlows/0/locations/16)
#  966|   				vgname = strdup(cft->root->key);
#  967|   			if (cft->root && cft->root->child)
#  968|-> 				dm_config_get_uint32(cft->root->child, "seqno", &seqno);
#  969|   		}
#  970|   		config_destroy(cft);

Scan Properties

analyzer-version-clippy1.90.0
analyzer-version-cppcheck2.18.3
analyzer-version-gcc15.2.1
analyzer-version-gcc-analyzer16.0.0
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
diffbase-analyzer-version-clippy1.90.0
diffbase-analyzer-version-cppcheck2.18.3
diffbase-analyzer-version-gcc15.2.1
diffbase-analyzer-version-gcc-analyzer16.0.0
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-43.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.20250521.132812.g8eff701.main-1.el9.noarch
diffbase-mock-configfedora-rawhide-gcc-latest-x86_64
diffbase-project-namelvm2-2.03.36-1.fc44
diffbase-store-results-to/tmp/tmpbfyfzxzt/lvm2-2.03.36-1.fc44.tar.xz
diffbase-time-created2025-10-28 19:27:03
diffbase-time-finished2025-10-28 19:31:16
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'gcc,cppcheck,shellcheck,clippy,unicontrol' '-o' '/tmp/tmpbfyfzxzt/lvm2-2.03.36-1.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpbfyfzxzt/lvm2-2.03.36-1.fc44.src.rpm'
diffbase-tool-versioncsmock-3.8.3.20251027.143044.ge6b947b-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-43.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250521.132812.g8eff701.main-1.el9.noarch
mock-configfedora-rawhide-gcc-latest-x86_64
project-namelvm2-2.03.34-2.fc43
store-results-to/tmp/tmpr074456d/lvm2-2.03.34-2.fc43.tar.xz
time-created2025-10-28 19:21:32
time-finished2025-10-28 19:26:18
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'gcc,cppcheck,shellcheck,clippy,unicontrol' '-o' '/tmp/tmpr074456d/lvm2-2.03.34-2.fc43.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpr074456d/lvm2-2.03.34-2.fc43.src.rpm'
tool-versioncsmock-3.8.3.20251027.143044.ge6b947b-1.el9