options: reject placement IDs larger than the max
authorVincent Fu <vincent.fu@samsung.com>
Thu, 4 Apr 2024 16:40:03 +0000 (16:40 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 24 Apr 2024 17:44:09 +0000 (13:44 -0400)
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@samsung.com>
options.c

index 7e589299d34a990ba0c8b510f5f4b5ee25d5ac3a..4065b7a0e420fb5a1be1a1b127b9c8583bf36071 100644 (file)
--- 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);