Fixed findings

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-457): [#def1]
libmtp-1.1.19/src/libusb1-glue.c:1089:23: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value '*handler.getfunc'
libmtp-1.1.19/src/libusb1-glue.c:1303:1: enter_function: entry to 'ptp_usb_senddata'
libmtp-1.1.19/src/libusb1-glue.c:1329:12: branch_true: following 'true' branch...
libmtp-1.1.19/src/libusb1-glue.c:1344:9: branch_true: ...to here
libmtp-1.1.19/src/libusb1-glue.c:1344:9: call_function: calling 'ptp_init_send_memory_handler' from 'ptp_usb_senddata'
libmtp-1.1.19/src/libusb1-glue.c:1344:9: return_function: returning to 'ptp_usb_senddata' from 'ptp_init_send_memory_handler'
libmtp-1.1.19/src/libusb1-glue.c:1346:15: call_function: calling 'ptp_write_func' from 'ptp_usb_senddata'
# 1087|         }
# 1088|       }
# 1089|->     int getfunc_ret = handler->getfunc(NULL, handler->priv,towrite,bytes,&towrite);
# 1090|       if (getfunc_ret != PTP_RC_OK) {
# 1091|         free(bytes);

Error: GCC_ANALYZER_WARNING (CWE-457): [#def2]
libmtp-1.1.19/src/libusb1-glue.c:1237:31: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value 'memhandler.priv'
libmtp-1.1.19/src/libusb1-glue.c:1303:1: enter_function: entry to 'ptp_usb_senddata'
libmtp-1.1.19/src/libusb1-glue.c:1329:12: branch_true: following 'true' branch...
libmtp-1.1.19/src/libusb1-glue.c:1344:9: branch_true: ...to here
libmtp-1.1.19/src/libusb1-glue.c:1344:9: call_function: calling 'ptp_init_send_memory_handler' from 'ptp_usb_senddata'
libmtp-1.1.19/src/libusb1-glue.c:1344:9: return_function: returning to 'ptp_usb_senddata' from 'ptp_init_send_memory_handler'
libmtp-1.1.19/src/libusb1-glue.c:1346:15: call_function: calling 'ptp_write_func' from 'ptp_usb_senddata'
libmtp-1.1.19/src/libusb1-glue.c:1346:15: return_function: returning to 'ptp_usb_senddata' from 'ptp_write_func'
libmtp-1.1.19/src/libusb1-glue.c:1347:9: call_function: inlined call to 'ptp_exit_send_memory_handler' from 'ptp_usb_senddata'
# 1235|   static uint16_t
# 1236|   ptp_exit_send_memory_handler (PTPDataHandler *handler) {
# 1237|-> 	PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
# 1238|   	/* data is owned by caller */
# 1239|   	free (priv);

Error: CPPCHECK_WARNING (CWE-476): [#def3]
libmtp-1.1.19/src/mtpz.c:88: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: str
#   86|   	char *result = str;
#   87|   
#   88|-> 	if ((result = fgets(str, num, stream)))
#   89|   	{
#   90|   		size_t newlen = strlen(result);

Error: COMPILER_WARNING (CWE-681): [#def4]
libmtp-1.1.19/src/mtpz.c: scope_hint: In function 'mtpz_loaddata'
libmtp-1.1.19/src/mtpz.c:151:29: warning[-Wpointer-sign]: pointer targets in assignment from 'char *' to 'unsigned char *' differ in signedness
#  151 |         MTPZ_ENCRYPTION_KEY = hex_to_bytes(hexenckey, strlen(hexenckey));
#      |                             ^
#  149|   	}
#  150|   
#  151|-> 	MTPZ_ENCRYPTION_KEY = hex_to_bytes(hexenckey, strlen(hexenckey));
#  152|   	if (!MTPZ_ENCRYPTION_KEY)
#  153|   	{

Scan Properties

analyzer-version-clippy1.92.0
analyzer-version-cppcheck2.19.1
analyzer-version-gcc16.0.0
analyzer-version-gcc-analyzer16.0.0
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
diffbase-analyzer-version-clippy1.92.0
diffbase-analyzer-version-cppcheck2.19.1
diffbase-analyzer-version-gcc16.0.0
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-39.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-x86_64
diffbase-project-namelibmtp-1.1.22-1.fc44
diffbase-store-results-to/tmp/tmp5j2br0pd/libmtp-1.1.22-1.fc44.tar.xz
diffbase-time-created2026-01-08 19:01:20
diffbase-time-finished2026-01-08 19:03:26
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,cppcheck,clippy,shellcheck,unicontrol' '-o' '/tmp/tmp5j2br0pd/libmtp-1.1.22-1.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmp5j2br0pd/libmtp-1.1.22-1.fc44.src.rpm'
diffbase-tool-versioncsmock-3.8.3.20251215.161544.g62de9a5-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-39.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-x86_64
project-namelibmtp-1.1.19-10.fc43
store-results-to/tmp/tmpjn9ktv4k/libmtp-1.1.19-10.fc43.tar.xz
time-created2026-01-08 18:58:16
time-finished2026-01-08 19:00:50
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,cppcheck,clippy,shellcheck,unicontrol' '-o' '/tmp/tmpjn9ktv4k/libmtp-1.1.19-10.fc43.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpjn9ktv4k/libmtp-1.1.19-10.fc43.src.rpm'
tool-versioncsmock-3.8.3.20251215.161544.g62de9a5-1.el9