Fixed defects

List of Defects

Error: GCC_ANALYZER_WARNING (CWE-775): [#def1]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/dmeventd/dmeventd.c: scope_hint: In function ‘_daemonize’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/dmeventd/dmeventd.c:2014:12: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/null", 0)’
# 2012|   
# 2013|   	/* coverity[leaked_handle] dont't care */
# 2014|-> 	if ((open("/dev/null", O_RDONLY) < 0) ||
# 2015|   	    (open("/dev/null", O_WRONLY) < 0) ||
# 2016|   	    (open("/dev/null", O_WRONLY) < 0))

Error: GCC_ANALYZER_WARNING (CWE-775): [#def2]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/dmeventd/dmeventd.c:2014:47: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/null", 1)’
# 2012|   
# 2013|   	/* coverity[leaked_handle] dont't care */
# 2014|-> 	if ((open("/dev/null", O_RDONLY) < 0) ||
# 2015|   	    (open("/dev/null", O_WRONLY) < 0) ||
# 2016|   	    (open("/dev/null", O_WRONLY) < 0))

Error: GCC_ANALYZER_WARNING (CWE-775): [#def3]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/dmeventd/dmeventd.c:2015:47: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/null", 1)’
# 2013|   	/* coverity[leaked_handle] dont't care */
# 2014|   	if ((open("/dev/null", O_RDONLY) < 0) ||
# 2015|-> 	    (open("/dev/null", O_WRONLY) < 0) ||
# 2016|   	    (open("/dev/null", O_WRONLY) < 0))
# 2017|   		exit(EXIT_DESC_OPEN_FAILURE);

Error: COMPILER_WARNING (CWE-9001): [#def4]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockctl.c:13: included_from: Included from here.
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-client.h: scope_hint: In function ‘do_kill’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-client.h:21:29: warning[-Winline]: inlining failed in call to ‘lvmlockd_open.constprop.0’: call is unlikely and code size would grow
#   21 | static inline daemon_handle lvmlockd_open(const char *sock)
#      |                             ^~~~~~~~~~~~~
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockctl.c:853:21: note: called from here
#  853 |         _lvmlockd = lvmlockd_open(NULL);
#      |                     ^~~~~~~~~~~~~~~~~~~
#   19|   /* Wrappers to open/close connection */
#   20|   
#   21|-> static inline daemon_handle lvmlockd_open(const char *sock)
#   22|   {
#   23|   	daemon_info lvmlockd_info = {

Error: COMPILER_WARNING (CWE-9001): [#def5]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-client.h: scope_hint: In function ‘do_kill’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-client.h:21:29: warning[-Winline]: inlining failed in call to ‘lvmlockd_open.constprop’: call is unlikely and code size would grow
#   21 | static inline daemon_handle lvmlockd_open(const char *sock)
#      |                             ^
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockctl.c:853:21: note: called from here
#  853 |         _lvmlockd = lvmlockd_open(NULL);
#      |                     ^
#   19|   /* Wrappers to open/close connection */
#   20|   
#   21|-> static inline daemon_handle lvmlockd_open(const char *sock)
#   22|   {
#   23|   	daemon_info lvmlockd_info = {

Error: COMPILER_WARNING: [#def6]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-dlm.c: scope_hint: In function ‘lm_get_lockspaces_dlm’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-dlm.c:849:17: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 64 bytes from a string of length 255
#  849 |                 strncpy(ls->name, de->d_name, MAX_NAME);
#      |                 ^
#  847|   
#  848|   		ls->lm_type = LD_LM_DLM;
#  849|-> 		strncpy(ls->name, de->d_name, MAX_NAME);
#  850|   		strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), MAX_NAME);
#  851|   		list_add_tail(&ls->list, ls_rejoin);

Error: GCC_ANALYZER_WARNING: [#def7]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-dlm.c: scope_hint: In function ‘lm_get_lockspaces_dlm’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-dlm.c:850:17: warning[-Wanalyzer-overlapping-buffers]: overlapping buffers passed as arguments to ‘strncpy’
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/all.h:34: included_from: Included from here.
lvm2-2.03.23-build/LVM2.2.03.23/tools/tool.h:22: included_from: Included from here.
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-dlm.c:14: included_from: Included from here.
/usr/include/string.h:144:14: note: the behavior of ‘strncpy’ is undefined for overlapping buffers
#  848|   		ls->lm_type = LD_LM_DLM;
#  849|   		strncpy(ls->name, de->d_name, MAX_NAME);
#  850|-> 		strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), MAX_NAME);
#  851|   		list_add_tail(&ls->list, ls_rejoin);
#  852|   	}

Error: COMPILER_WARNING: [#def8]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-sanlock.c: scope_hint: In function ‘lm_able_gl_sanlock’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-sanlock.c:1147:17: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 64 bytes from a string of length 64
# 1147 |                 strncpy(gl_lsname_sanlock, ls->name, MAX_NAME);
#      |                 ^
# 1145|   
# 1146|   	if (enable)
# 1147|-> 		strncpy(gl_lsname_sanlock, ls->name, MAX_NAME);
# 1148|   
# 1149|   	if (!enable && !strcmp(gl_lsname_sanlock, ls->name))

Error: COMPILER_WARNING: [#def9]
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-sanlock.c: scope_hint: In function ‘lm_prepare_lockspace_sanlock’
lvm2-2.03.23-build/LVM2.2.03.23/daemons/lvmlockd/lvmlockd-sanlock.c:1420:9: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 48 bytes from a string of length 64
# 1420 |         strncpy(lsname, ls->name, SANLK_NAME_LEN);
#      |         ^
# 1418|   
# 1419|   	memset(lsname, 0, sizeof(lsname));
# 1420|-> 	strncpy(lsname, ls->name, SANLK_NAME_LEN);
# 1421|   
# 1422|   	memcpy(lms->ss.name, lsname, SANLK_NAME_LEN);

Error: COMPILER_WARNING: [#def10]
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/ioctl/libdm-iface.c: scope_hint: In function ‘dm_task_run’
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/ioctl/libdm-iface.c:1259:25: warning[-Wstringop-truncation]: ‘__strncpy_chk’ specified bound 128 equals destination size
# 1259 |                         strncpy(buf, names->name, len);
#      |                         ^
# 1257|   		names = (struct dm_names *)((char *) names + next);
# 1258|   		if (names->dev == dev) {
# 1259|-> 			strncpy(buf, names->name, len);
# 1260|   			r = 1;
# 1261|   			break;

Error: COMPILER_WARNING: [#def11]
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/ioctl/libdm-iface.c:1429:17: warning[-Wstringop-truncation]: ‘__strncpy_chk’ specified bound 128 equals destination size
# 1429 |                 strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
#      |                 ^
# 1427|   			      dmt->major < 0))
# 1428|   		/* coverity[buffer_size_warning] */
# 1429|-> 		strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
# 1430|   
# 1431|   	if (DEV_UUID(dmt))

Error: COMPILER_WARNING: [#def12]
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/ioctl/libdm-iface.c:1433:17: warning[-Wstringop-truncation]: ‘__strncpy_chk’ specified bound 129 equals destination size
# 1433 |                 strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
#      |                 ^
# 1431|   	if (DEV_UUID(dmt))
# 1432|   		/* coverity[buffer_size_warning] */
# 1433|-> 		strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
# 1434|   
# 1435|   	if (dmt->type == DM_DEVICE_SUSPEND)

Error: COMPILER_WARNING: [#def13]
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/libdm-deptree.c: scope_hint: In function ‘dm_tree_find_node_by_uuid’
lvm2-2.03.23-build/LVM2.2.03.23/device_mapper/libdm-deptree.c:617:32: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 129 equals destination size
#  617 |                         (void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
#      |                                ^
#  615|   				continue;
#  616|   
#  617|-> 			(void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
#  618|   			uuid_without_suffix[suffix_position - uuid] = '\0';
#  619|   

Error: COMPILER_WARNING: [#def14]
lvm2-2.03.23-build/LVM2.2.03.23/lib/device/device_id.c:1211:33: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 4095 bytes from a string of length 4095
# 1211 |                                 strncpy(devices_file_hostname_orig, check_id, PATH_MAX-1);
#      |                                 ^
# 1209|   			/* Save original for lvmdevices output. */
# 1210|   			if (!strcmp(cmd->name, "lvmdevices"))
# 1211|-> 				strncpy(devices_file_hostname_orig, check_id, PATH_MAX-1);
# 1212|   
# 1213|   			if (!cmd->device_ids_check_hostname)

Error: COMPILER_WARNING: [#def15]
lvm2-2.03.23-build/LVM2.2.03.23/lib/device/device_id.c: scope_hint: In function ‘device_ids_read’
lvm2-2.03.23-build/LVM2.2.03.23/lib/device/device_id.c:1231:33: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 4095 bytes from a string of length 4095
# 1231 |                                 strncpy(devices_file_product_uuid_orig, check_id, PATH_MAX-1);
#      |                                 ^
# 1229|   			/* Save original for lvmdevices output. */
# 1230|   			if (!strcmp(cmd->name, "lvmdevices"))
# 1231|-> 				strncpy(devices_file_product_uuid_orig, check_id, PATH_MAX-1);
# 1232|   
# 1233|   			if (!cmd->device_ids_check_product_uuid)

Error: COMPILER_WARNING: [#def16]
lvm2-2.03.23-build/LVM2.2.03.23/lib/device/online.c: scope_hint: In function ‘get_pvs_lookup’
lvm2-2.03.23-build/LVM2.2.03.23/lib/device/online.c:435:25: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 127
#  435 |                         strncpy(po->vgname, file_vgname, NAME_LEN-1);
#      |                         ^
#  433|   			po->devno = MKDEV(file_major, file_minor);
#  434|   		if (file_vgname[0])
#  435|-> 			strncpy(po->vgname, file_vgname, NAME_LEN-1);
#  436|   		if (file_devname[0])
#  437|   			strncpy(po->devname, file_devname, NAME_LEN-1);

Error: COMPILER_WARNING: [#def17]
lvm2-2.03.23-build/LVM2.2.03.23/lib/device/online.c:437:25: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 127
#  437 |                         strncpy(po->devname, file_devname, NAME_LEN-1);
#      |                         ^
#  435|   			strncpy(po->vgname, file_vgname, NAME_LEN-1);
#  436|   		if (file_devname[0])
#  437|-> 			strncpy(po->devname, file_devname, NAME_LEN-1);
#  438|   
#  439|   		log_debug("Found PV online lookup %s for VG %s on %s.", path, vgname, file_devname);

Error: COMPILER_WARNING: [#def18]
lvm2-2.03.23-build/LVM2.2.03.23/lib/log/log.c: scope_hint: In function ‘reopen_standard_stream’
lvm2-2.03.23-build/LVM2.2.03.23/lib/log/log.c:209:9: warning[-Wuse-after-free]: pointer ‘old_stream_40’ may be used after ‘fclose’
#  209 |         _check_and_replace_standard_log_streams(old_stream, new_stream);
#      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lvm2-2.03.23-build/LVM2.2.03.23/lib/log/log.c:193:13: note: call to ‘fclose’ here
#  193 |         if (fclose(old_stream))
#      |             ^~~~~~~~~~~~~~~~~~
#  207|   	}
#  208|   
#  209|-> 	_check_and_replace_standard_log_streams(old_stream, new_stream);
#  210|   
#  211|   	*stream = new_stream;

Error: COMPILER_WARNING: [#def19]
lvm2-2.03.23-build/LVM2.2.03.23/libdm/ioctl/libdm-iface.c: scope_hint: In function ‘dm_task_run_v1_02_197’
lvm2-2.03.23-build/LVM2.2.03.23/libdm/ioctl/libdm-iface.c:1131:25: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 128 equals destination size
# 1131 |                         strncpy(buf, names->name, len);
#      |                         ^
# 1129|   		names = (struct dm_names *)((char *) names + next);
# 1130|   		if (names->dev == dev) {
# 1131|-> 			strncpy(buf, names->name, len);
# 1132|   			r = 1;
# 1133|   			break;

Error: COMPILER_WARNING: [#def20]
lvm2-2.03.23-build/LVM2.2.03.23/libdm/ioctl/libdm-iface.c:1286:17: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 128 equals destination size
# 1286 |                 strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
#      |                 ^
# 1284|   		 * passed dev_name is useful for better error/debug messages */
# 1285|   		/* coverity[buffer_size_warning] */
# 1286|-> 		strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
# 1287|   
# 1288|   	if (DEV_UUID(dmt))

Error: COMPILER_WARNING: [#def21]
lvm2-2.03.23-build/LVM2.2.03.23/libdm/ioctl/libdm-iface.c:1290:17: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 129 equals destination size
# 1290 |                 strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
#      |                 ^
# 1288|   	if (DEV_UUID(dmt))
# 1289|   		/* coverity[buffer_size_warning] */
# 1290|-> 		strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
# 1291|   
# 1292|   	if (dmt->type == DM_DEVICE_SUSPEND)

Error: COMPILER_WARNING: [#def22]
lvm2-2.03.23-build/LVM2.2.03.23/libdm/libdm-deptree.c: scope_hint: In function ‘dm_tree_find_node_by_uuid’
lvm2-2.03.23-build/LVM2.2.03.23/libdm/libdm-deptree.c:577:32: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 129 equals destination size
#  577 |                         (void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
#      |                                ^
#  575|   				continue;
#  576|   
#  577|-> 			(void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
#  578|   			uuid_without_suffix[suffix_position - uuid] = '\0';
#  579|   

Error: COMPILER_WARNING (CWE-9001): [#def23]
lvm2-2.03.23-build/LVM2.2.03.23/test/lib/brick-shelltest.h:888:8: warning[-Winline]: inlining failed in call to ‘brick::shelltest::TestCase::TestCase(brick::shelltest::TestCase const&)’: --param max-inline-insns-single limit reached
#  888 | struct TestCase {
#      |        ^~~~~~~~
/usr/include/c++/14/x86_64-redhat-linux/bits/c++allocator.h:33: included_from: Included from here.
/usr/include/c++/14/bits/allocator.h:46: included_from: Included from here.
/usr/include/c++/14/vector:63: included_from: Included from here.
lvm2-2.03.23-build/LVM2.2.03.23/test/lib/brick-shelltest.h:56: included_from: Included from here.
/usr/include/c++/14/bits/new_allocator.h:191:11: note: called from here
#  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
#      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  886|   };
#  887|   
#  888|-> struct TestCase {
#  889|       TestProcess child;
#  890|       std::string name, flavour;

Error: CLANG_WARNING: [#def24]
lvm2-2.03.23-build/LVM2.2.03.23/tools/command.c:2607:5: warning[deadcode.DeadStores]: Value stored to 'need_ro_indent_end' is never read
# 2605|   			if ((cmd->ro_count > 2) && (sep == 2)) {
# 2606|   				printf("\n.RS 5\n");
# 2607|-> 				need_ro_indent_end = 1;
# 2608|   			}
# 2609|   

Error: CLANG_WARNING: [#def25]
lvm2-2.03.23-build/LVM2.2.03.23/tools/toollib.c:4386:20: warning[core.NullDereference]: Access to field 'name' results in a dereference of a null pointer (loaded from variable 'vg')
# 4384|   	}
# 4385|   
# 4386|-> 	if (!is_orphan_vg(vg->name))
# 4387|   		log_set_report_object_group_and_group_id(vg->name, vg_uuid);
# 4388|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def26]
lvm2-2.03.23-build/LVM2.2.03.23/tools/vgcfgbackup.c: scope_hint: In function ‘_vg_backup_single’
lvm2-2.03.23-build/LVM2.2.03.23/tools/vgcfgbackup.c:67:20: warning[-Wanalyzer-malloc-leak]: leak of ‘_expand_filename(arg_value(cmd, 192), *vg.name,  last_filename)’
#   65|   			return_ECMD_FAILED;
#   66|   
#   67|-> 		if (!backup_to_file(filename, vg->cmd->cmd_line, vg))
#   68|   			return_ECMD_FAILED;
#   69|   	} else {

Scan Properties

analyzer-version-clang18.1.7
analyzer-version-cppcheck2.14.2
analyzer-version-gcc14.1.1
analyzer-version-gcc-analyzer14.1.1
analyzer-version-shellcheck0.10.0
diffbase-analyzer-version-clang18.1.7
diffbase-analyzer-version-cppcheck2.14.2
diffbase-analyzer-version-gcc14.1.1
diffbase-analyzer-version-gcc-analyzer14.1.1
diffbase-analyzer-version-shellcheck0.10.0
diffbase-enabled-pluginsclang, cppcheck, gcc, shellcheck
diffbase-exit-code0
diffbase-hostip-172-16-1-213.us-west-2.compute.internal
diffbase-mock-configfedora-41-x86_64
diffbase-project-namelvm2-2.03.24-3.fc41
diffbase-store-results-to/tmp/tmp3wxqwdje/lvm2-2.03.24-3.fc41.tar.xz
diffbase-time-created2024-07-03 16:13:43
diffbase-time-finished2024-07-03 16:19:01
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmp3wxqwdje/lvm2-2.03.24-3.fc41.tar.xz' '--gcc-analyze' '/tmp/tmp3wxqwdje/lvm2-2.03.24-3.fc41.src.rpm'
diffbase-tool-versioncsmock-3.5.3-1.el9
enabled-pluginsclang, cppcheck, gcc, shellcheck
exit-code0
hostip-172-16-1-213.us-west-2.compute.internal
mock-configfedora-41-x86_64
project-namelvm2-2.03.23-1.fc40
store-results-to/tmp/tmpovaqkw0p/lvm2-2.03.23-1.fc40.tar.xz
time-created2024-07-03 16:07:54
time-finished2024-07-03 16:13:29
titleFixed defects
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmpovaqkw0p/lvm2-2.03.23-1.fc40.tar.xz' '--gcc-analyze' '/tmp/tmpovaqkw0p/lvm2-2.03.23-1.fc40.src.rpm'
tool-versioncsmock-3.5.3-1.el9