From 3dabef7c3139835d4afada65fb3f7ac8609e42eb Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Thu, 4 Apr 2024 16:40:03 +0000 Subject: [PATCH] options: reject placement IDs larger than the max 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 --- options.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/options.c b/options.c index 7e589299..4065b7a0 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.25.1