From b851c2db8104e35b838ee3067d3694f6b98582b9 Mon Sep 17 00:00:00 2001 From: piernov Date: Sat, 20 Jul 2024 17:45:14 +0200 Subject: [PATCH] io.c: fix possible buffer overflow in find_all_devices_ccc() Was causing crash with -D_FORTIFY_SOURCE=3 --- src/opensuperclone/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opensuperclone/io.c b/src/opensuperclone/io.c index 9813ee5..afffd42 100644 --- a/src/opensuperclone/io.c +++ b/src/opensuperclone/io.c @@ -6258,7 +6258,7 @@ int find_all_devices_ccc(void) sscanf(line, "%s %s %s %[^\n]", name, raw_size, raw_bytes_per_sec, model); strcpy(drive_list_ccc[device_count_ccc], "/dev/"); strcat(drive_list_ccc[device_count_ccc], name); - strncpy(model_ccc[device_count_ccc], model, sizeof(model_ccc)); + strncpy(model_ccc[device_count_ccc], model, sizeof(model_ccc[device_count_ccc]) - 1); // get device info long long size = strtoull(raw_size, NULL, 0); long long bytes_per_sec = strtoull(raw_bytes_per_sec, NULL, 0);