[PATCH 5/9] options: reject placement IDs larger than the max

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Placement IDs are a 16-bit value. So we should notify users if the
provided placement IDs are too large.

Signed-off-by: Vincent Fu <vincent.fu@xxxxxxxxxxx>
---
 options.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/options.c b/options.c
index 09a24652..ece90c72 100644
--- a/options.c
+++ b/options.c
@@ -270,8 +270,15 @@ static int str_fdp_pli_cb(void *data, const char *input)
 	strip_blank_front(&str);
 	strip_blank_end(str);
 
-	while ((v = strsep(&str, ",")) != NULL && i < FIO_MAX_DP_IDS)
-		td->o.dp_ids[i++] = strtoll(v, NULL, 0);
+	while ((v = strsep(&str, ",")) != NULL && i < FIO_MAX_DP_IDS) {
+		unsigned long long id = strtoll(v, NULL, 0);
+		if (id > 0xFFFF) {
+			log_err("Placement IDs cannot exceed 0xFFFF\n");
+			free(p);
+			return 1;
+		}
+		td->o.dp_ids[i++] = id;
+	}
 	free(p);
 
 	qsort(td->o.dp_ids, i, sizeof(*td->o.dp_ids), fio_fdp_cmp);
-- 
2.43.0





[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux