Commit 1110b71e authored by Chris Clayton's avatar Chris Clayton Committed by Peter Hutterer

kdrive: fix build error on gcc 4.8 for out-of-bounds array access

I'm getting a error building xorg-server-1.14.1.902 with thelatest snapshot
of gcc-4.8:

input.c:225:43: error: array subscript is above array bounds
[-Werror=array-bounds]

This is because kdNumInputFds can become equal to KD_MAX_INPUT_FDS in
KdRegisterFd(). This means that in KdUnregisterFd(), kdInputFds[j + 1] can
be beyond the end of the array.
Signed-off-by: default avatarChris Clayton <chris2553@googlemail.com>
Reviewed-by: default avatarKeith Packard <keithp@keithp.com>
Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 94d4e29a
...@@ -221,7 +221,7 @@ KdUnregisterFd(void *closure, int fd, Bool do_close) ...@@ -221,7 +221,7 @@ KdUnregisterFd(void *closure, int fd, Bool do_close)
if (do_close) if (do_close)
close(kdInputFds[i].fd); close(kdInputFds[i].fd);
kdNumInputFds--; kdNumInputFds--;
for (j = i; j < kdNumInputFds; j++) for (j = i; j < (kdNumInputFds - 1); j++)
kdInputFds[j] = kdInputFds[j + 1]; kdInputFds[j] = kdInputFds[j + 1];
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment