summaryrefslogtreecommitdiff
path: root/src/glx/glxglvnd.c
diff options
context:
space:
mode:
authorStefan Dirsch <sndirsch@suse.de>2016-07-14 15:21:20 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2016-07-20 16:05:17 +0100
commit27ef7bfd6cd2d960844f4c79d6dddc0bda0b20b0 (patch)
tree64c8b92d5f5344fd3fbdeb8812e5959d8bddc490 /src/glx/glxglvnd.c
parent9e1248d0752e692714b58ef1f2211ec7e172c8cf (diff)
downloadmesa-27ef7bfd6cd2d960844f4c79d6dddc0bda0b20b0.tar.gz
mesa-27ef7bfd6cd2d960844f4c79d6dddc0bda0b20b0.tar.bz2
mesa-27ef7bfd6cd2d960844f4c79d6dddc0bda0b20b0.zip
Avoid overflow in 'last' variable of FindGLXFunction(...)
This 'last' variable used in FindGLXFunction(...) may become negative, but has been defined as unsigned int resulting in an overflow, finally resulting in a segfault when accessing _glXDispatchTableStrings[...]. Fixed this by definining it as signed int. 'first' variable also needs to be defined as signed int. Otherwise condition for while loop fails due to C implicitly converting signed to unsigned values before comparison. Cc: <mesa-stable@lists.freedesktop.org> Signed-off-by: Stefan Dirsch <sndirsch@suse.de> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'src/glx/glxglvnd.c')
-rw-r--r--src/glx/glxglvnd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/glx/glxglvnd.c b/src/glx/glxglvnd.c
index b7252a791ad..962eda8bb5b 100644
--- a/src/glx/glxglvnd.c
+++ b/src/glx/glxglvnd.c
@@ -19,11 +19,11 @@ static void *__glXGLVNDGetProcAddress(const GLubyte *procName)
static unsigned FindGLXFunction(const GLubyte *name)
{
- unsigned first = 0;
- unsigned last = DI_FUNCTION_COUNT - 1;
+ int first = 0;
+ int last = DI_FUNCTION_COUNT - 1;
while (first <= last) {
- unsigned middle = (first + last) / 2;
+ int middle = (first + last) / 2;
int comp = strcmp((const char *) name,
__glXDispatchTableStrings[middle]);