From fe756b133ae8ef2dcc33571ffc323ce14b7f50ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Frohm=C3=BCller?= Date: Sun, 14 Jun 2026 16:46:09 +0200 Subject: [PATCH] Fix type mismatch, strncpy truncation, and off-by-one error in usb error prints --- src/opensuperclone/clone_gui.c | 2 +- src/opensuperclone/opensuperclone.c | 4 ++-- src/opensuperclone/usbrelay.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/opensuperclone/clone_gui.c b/src/opensuperclone/clone_gui.c index 8532cc8..4dce076 100644 --- a/src/opensuperclone/clone_gui.c +++ b/src/opensuperclone/clone_gui.c @@ -597,7 +597,7 @@ int print_gui_error_message_ccc(char *message, char *title, int type) { GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *dialog; - GtkDialogFlags message_type; + GtkMessageType message_type; if (type) { message_type = GTK_MESSAGE_WARNING; diff --git a/src/opensuperclone/opensuperclone.c b/src/opensuperclone/opensuperclone.c index 44778a5..4c710a5 100644 --- a/src/opensuperclone/opensuperclone.c +++ b/src/opensuperclone/opensuperclone.c @@ -13570,8 +13570,8 @@ int process_source_ccc(void) raw_alignment[0] = '\0'; sscanf(line, "%s %s %s %s %s %[^\n]", name, raw_size, raw_bytes_per_log_sec, raw_bytes_per_phy_sec, raw_alignment, model); fprintf(stdout, "model=%s\n", model); - strncpy(current_model_ccc, model, sizeof(current_model_ccc)); - strncpy(current_source_model_ccc, model, sizeof(current_source_model_ccc)); + strncpy(current_model_ccc, model, sizeof(current_model_ccc) - 1); + strncpy(current_source_model_ccc, model, sizeof(current_source_model_ccc) - 1); // get device info long long size = strtoull(raw_size, NULL, 0); long long bytes_per_log_sec = strtoull(raw_bytes_per_log_sec, NULL, 0); diff --git a/src/opensuperclone/usbrelay.c b/src/opensuperclone/usbrelay.c index 33d7ce3..553295d 100644 --- a/src/opensuperclone/usbrelay.c +++ b/src/opensuperclone/usbrelay.c @@ -68,7 +68,7 @@ int find_all_usb_devices_ccc(void) } else { - fprintf(stdout, "Error: Unnable to get vendor string %04x:%04x (%s)\n", usb_vendor_id_ccc[i], usb_product_id_ccc[i], strerror(errno)); + fprintf(stdout, "Error: Unnable to get vendor string %04x:%04x (%s)\n", usb_vendor_id_ccc[usb_device_count_ccc], usb_product_id_ccc[usb_device_count_ccc], strerror(errno)); } rval = usb_get_string_simple(dev_handle, dev->descriptor.iProduct, buffer, sizeof(buffer)); @@ -78,7 +78,7 @@ int find_all_usb_devices_ccc(void) } else { - fprintf(stdout, "Error: Unable to get product string %04x:%04x (%s)\n", usb_vendor_id_ccc[i], usb_product_id_ccc[i], strerror(errno)); + fprintf(stdout, "Error: Unable to get product string %04x:%04x (%s)\n", usb_vendor_id_ccc[usb_device_count_ccc], usb_product_id_ccc[usb_device_count_ccc], strerror(errno)); } rval = usb_get_string_simple(dev_handle, dev->descriptor.iSerialNumber, buffer, sizeof(buffer)); @@ -88,7 +88,7 @@ int find_all_usb_devices_ccc(void) } else { - fprintf(stdout, "Error: Unable to get serial string %04x:%04x (%s)\n", usb_vendor_id_ccc[i], usb_product_id_ccc[i], strerror(errno)); + fprintf(stdout, "Error: Unable to get serial string %04x:%04x (%s)\n", usb_vendor_id_ccc[usb_device_count_ccc], usb_product_id_ccc[usb_device_count_ccc], strerror(errno)); } // if the device is known to have an extra id or serial then get it @@ -110,7 +110,7 @@ int find_all_usb_devices_ccc(void) } else { - fprintf(stdout, "Failed to get special id %04x:%04x, %d (%s)\n", usb_vendor_id_ccc[i], usb_product_id_ccc[i], bytesreceived, strerror(errno)); + fprintf(stdout, "Failed to get special id %04x:%04x, %d (%s)\n", usb_vendor_id_ccc[usb_device_count_ccc], usb_product_id_ccc[usb_device_count_ccc], bytesreceived, strerror(errno)); } // if it is a known usb relay then mark it usb_known_relay_ccc[usb_device_count_ccc] = 1;