From 58cb4f6f2767999f994cde659742b80d08ca0fa3 Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 9 May 2018 01:08:41 +0000 Subject: [PATCH] - Fixed out-by-one error when checking tag ID is valid. - Pass GfxBase to check_sizes() so it still works when debug code is enabled. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@55163 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/graphics/getdisplayinfodata.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rom/graphics/getdisplayinfodata.c b/rom/graphics/getdisplayinfodata.c index 25041164d0..4c1ebc6618 100644 --- a/rom/graphics/getdisplayinfodata.c +++ b/rom/graphics/getdisplayinfodata.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2017, The AROS Development Team. All rights reserved. + Copyright © 1995-2018, The AROS Development Team. All rights reserved. $Id$ Desc: Graphics function GetDisplayInfoData() @@ -7,10 +7,10 @@ */ #include -#include #include #include #include +#include #include #include @@ -30,7 +30,7 @@ static const ULONG size_checks[] = #define KNOWN_IDS 4 -static ULONG check_sizes(ULONG tagID, ULONG size); +static ULONG check_sizes(ULONG tagID, ULONG size, struct GfxBase *GfxBase); static UBYTE popcount(IPTR x); #define DLONGSZ (sizeof (ULONG) * 2) @@ -178,7 +178,7 @@ static inline void CalcScreenResolution(Point *res, const struct MonitorSpec *ms , (ULONG)handle, tagID)); /* Build the queryheader */ - structsize = check_sizes(tagID, size); + structsize = check_sizes(tagID, size, GfxBase); if (!structsize) return 0; qh = AllocMem(structsize, MEMF_CLEAR); @@ -530,15 +530,15 @@ static inline void CalcScreenResolution(Point *res, const struct MonitorSpec *ms /****************************************************************************************/ -static ULONG check_sizes(ULONG tagID, ULONG size) +static ULONG check_sizes(ULONG tagID, ULONG size, struct GfxBase *GfxBase) { ULONG idx; idx = DTAG_TO_IDX(tagID); - if (idx > KNOWN_IDS) + if (idx >= KNOWN_IDS) { - D(bug("!!! INVALID tagID TO GetDisplayInfoData")); + D(bug("[GetDisplayInfoData] INVALID tagID 0x%lx (idx=%ld)!\n", tagID, idx)); return 0; } -- 2.11.4.GIT