diff options
author | Julius Werner <jwerner@chromium.org> | 2019-08-15 21:25:16 -0700 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2019-08-19 21:12:31 +0000 |
commit | 5c82c444fba6fd3cf506c777546a5481755808ff (patch) | |
tree | f268783ea81a904f37961891fdc4cd8dab323445 | |
parent | 0889e9392c6f544127e64889df2abdfe8da2e252 (diff) | |
download | coreboot-5c82c444fba6fd3cf506c777546a5481755808ff.tar.xz |
commonlib/region: Fix up overflow check in region_is_subregion()
region_is_subregion() checks whether the size of the inner region is
larger than the size of the outer region... which isn't really necessary
because we're already checking the starts and ends of both regions.
Maybe this was added to ensure the inner region doesn't overflow? But
it's not guaranteed to catch that in all cases. Replace it with a proper
overflow check.
Change-Id: I9e442053584a479a323c1fa1c0591934ff83eb10
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34892
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
-rw-r--r-- | src/commonlib/region.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/commonlib/region.c b/src/commonlib/region.c index 541a125ad4..b5858f91c0 100644 --- a/src/commonlib/region.c +++ b/src/commonlib/region.c @@ -27,10 +27,10 @@ int region_is_subregion(const struct region *p, const struct region *c) if (region_offset(c) < region_offset(p)) return 0; - if (region_sz(c) > region_sz(p)) + if (region_end(c) > region_end(p)) return 0; - if (region_end(c) > region_end(p)) + if (region_end(c) < region_offset(c)) return 0; return 1; |