Fix type mismatch, strncpy truncation, and off-by-one error in usb error prints

This commit is contained in:
Julian Frohmüller
2026-06-14 16:46:09 +02:00
parent 92228df860
commit fe756b133a
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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);
+4 -4
View File
@@ -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;