From faab7229c9da2881bdcde6cf1585435b03c7b45f Mon Sep 17 00:00:00 2001 From: nvt-se Date: Tue, 25 Jan 2011 18:39:09 +0000 Subject: [PATCH] Must check the storage boundary in find_contiguous_pages. --- core/cfs/cfs-coffee.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index e96fe4be5..0f5ca4152 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -515,6 +515,10 @@ find_contiguous_pages(coffee_page_t amount) if(HDR_FREE(hdr)) { if(start == INVALID_PAGE) { start = page; + if(start + amount >= COFFEE_PAGE_COUNT) { + /* We can stop immediately if the remaining pages are not enough. */ + break; + } } /* All remaining pages in this sector are free --