Fixed findings

List of Findings

Error: CPPCHECK_WARNING (CWE-758): [#def1]
parted-3.6/lib/malloc/dynarray_emplace_enlarge.c:59: error[shiftTooManyBitsSigned]: Shifting signed 64-bit value by 63 bits is undefined behaviour
#   57|   
#   58|     size_t new_size;
#   59|->   if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size))
#   60|       return false;
#   61|     void *new_array;

Error: CPPCHECK_WARNING (CWE-758): [#def2]
parted-3.6/lib/malloc/dynarray_resize.c:45: error[shiftTooManyBitsSigned]: Shifting signed 64-bit value by 63 bits is undefined behaviour
#   43|   
#   44|     size_t new_size_bytes;
#   45|->   if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes))
#   46|       {
#   47|         /* Overflow.  */

Error: CPPCHECK_WARNING (CWE-758): [#def3]
parted-3.6/lib/xstrtol.c:54: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
#   52|   {
#   53|     __strtol_t scaled;
#   54|->   if (INT_MULTIPLY_WRAPV (*x, scale_factor, &scaled))
#   55|       {
#   56|         *x = *x < 0 ? TYPE_MINIMUM (__strtol_t) : TYPE_MAXIMUM (__strtol_t);

Error: COMPILER_WARNING (CWE-704): [#def4]
parted-3.6/parted/strlist.c: scope_hint: In function 'wchar_strchr'
parted-3.6/parted/strlist.c:61:16: warning[-Wdiscarded-qualifiers]: return discards 'const' qualifier from pointer target type
#   61 |         return wcschr (str, ch);
#      |                ^~~~~~
#   59|   {
#   60|   #ifdef ENABLE_NLS
#   61|-> 	return wcschr (str, ch);
#   62|   #else
#   63|   	return strchr (str, ch);

Error: COMPILER_WARNING (CWE-704): [#def5]
parted-3.6/parted/strlist.c:61:16: warning[-Wdiscarded-qualifiers]: return discards 'const' qualifier from pointer target type
#   59|   {
#   60|   #ifdef ENABLE_NLS
#   61|-> 	return wcschr (str, ch);
#   62|   #else
#   63|   	return strchr (str, ch);

Error: CPPCHECK_WARNING (CWE-401): [#def6]
parted-3.6/parted/strlist.c:168: error[memleakOnRealloc]: Common realloc mistake: 'result' nulled but not freed upon failure
#  166|   		goto error;
#  167|   
#  168|-> 	result = realloc (result, strlen (result) + 1);
#  169|   	if (!result)
#  170|   		goto error;

Error: CPPCHECK_WARNING (CWE-401): [#def7]
parted-3.6/parted/strlist.c:367: error[memleakOnRealloc]: Common realloc mistake: 'str' nulled but not freed upon failure
#  365|   			length += strlen (tmp);
#  366|   
#  367|-> 			str = realloc (str, length);
#  368|   			strcpy (str + pos, tmp);
#  369|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def8]
parted-3.6/parted/strlist.c:368:25: warning[-Wanalyzer-null-argument]: use of NULL 'str' where non-null expected
parted-3.6/parted/strlist.c:354:1: enter_function: entry to 'str_list_convert'
parted-3.6/parted/strlist.c:361:27: branch_true: following 'true' branch (when 'walk' is non-NULL)...
parted-3.6/parted/strlist.c:362:21: branch_true: ...to here
parted-3.6/parted/strlist.c:362:20: branch_true: following 'true' branch...
parted-3.6/parted/strlist.c:363:39: branch_true: ...to here
parted-3.6/parted/strlist.c:363:39: call_function: calling 'wchar_to_str' from 'str_list_convert'
parted-3.6/parted/strlist.c:363:39: return_function: returning to 'str_list_convert' from 'wchar_to_str'
parted-3.6/parted/strlist.c:368:25: danger: argument 1 ('str + (sizetype)pos') NULL where non-null expected
#  366|   
#  367|   			str = realloc (str, length);
#  368|-> 			strcpy (str + pos, tmp);
#  369|   
#  370|   			pos = length - 1;

Scan Properties

analyzer-version-clippy1.95.0
analyzer-version-cppcheck2.20.0
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.95.0
diffbase-analyzer-version-cppcheck2.20.0
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-238.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-nameparted-3.7-2.fc45
diffbase-store-results-to/tmp/tmp4dpkp0ne/parted-3.7-2.fc45.tar.xz
diffbase-time-created2026-06-01 15:35:32
diffbase-time-finished2026-06-01 15:37:19
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'shellcheck,cppcheck,clippy,unicontrol,gcc' '-o' '/tmp/tmp4dpkp0ne/parted-3.7-2.fc45.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmp4dpkp0ne/parted-3.7-2.fc45.src.rpm'
diffbase-tool-versioncsmock-3.8.5.20260529.133039.g6f3b5c6-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-238.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-nameparted-3.6-14.fc44
store-results-to/tmp/tmppt95wmkn/parted-3.6-14.fc44.tar.xz
time-created2026-06-01 15:32:07
time-finished2026-06-01 15:35:10
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'shellcheck,cppcheck,clippy,unicontrol,gcc' '-o' '/tmp/tmppt95wmkn/parted-3.6-14.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmppt95wmkn/parted-3.6-14.fc44.src.rpm'
tool-versioncsmock-3.8.5.20260529.133039.g6f3b5c6-1.el9