From bacc94233368cf136b55e2574e969e7f53b31c6c Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Wed, 10 Jan 2018 02:03:32 +0000 Subject: [PATCH] allocation: Avoid exceeding array bounds in allocation tag code If _limit_to_one_area_per_tag() changes nothing it writes beyond the array. --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index 345c4720c..897576c69 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.178 - ===================================== + Avoid exceeding array bounds in allocation tag processing. Refactor metadata reading code to use callback functions. Move memory allocation for the key dev_reads into the device layer. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 70dc2d92c..ac30dadeb 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -2737,7 +2737,8 @@ static int _limit_to_one_area_per_tag(struct alloc_handle *ah, struct alloc_stat s++; } - alloc_state->areas[u].pva = NULL; + if (u < alloc_state->areas_size) + alloc_state->areas[u].pva = NULL; return 1; }