Skip to content

Commit

Permalink
Added some sanity checks to prevent buffer overflows.
Browse files Browse the repository at this point in the history
Fixes Bugzilla #1074. (I think.)
  • Loading branch information
icculus committed Dec 30, 2011
1 parent ce04030 commit 6d1433f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -935,6 +935,10 @@ void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
SDL_logical_joydecl(SDL_Joystick *logicaljoy = NULL);
SDL_logical_joydecl(struct joystick_logical_mapping* hats = NULL);

if (stick->nhats <= hat) {
return; /* whoops, that shouldn't happen! */
}

the_hat = &stick->hwdata->hats[hat];
if ( value < 0 ) {
value = 0;
Expand Down Expand Up @@ -973,6 +977,9 @@ void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
static __inline__
void HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value)
{
if ((stick->nballs <= ball) || (axis >= 2)) {
return; /* whoops, that shouldn't happen! */
}
stick->hwdata->balls[ball].axis[axis] += value;
}

Expand Down

0 comments on commit 6d1433f

Please sign in to comment.