Fix potential overflow when reading very long Controller ID string

This commit is contained in:
Dimitris Panokostas 2017-09-21 17:48:13 +02:00
parent 1f2a070c09
commit 5042b7bae4

View file

@ -296,7 +296,7 @@ static int init_joystick(void)
for (int cpt; cpt < nr_joysticks; cpt++)
{
Joysticktable[cpt] = SDL_JoystickOpen(cpt);
strncpy(JoystickName[cpt], SDL_JoystickName(cpt), 80);
strncpy(JoystickName[cpt], SDL_JoystickName(cpt), sizeof JoystickName[cpt]);
printf("Joystick %i : %s\n", cpt, JoystickName[cpt]);
printf(" Buttons: %i Axis: %i Hats: %i\n", SDL_JoystickNumButtons(Joysticktable[cpt]), SDL_JoystickNumAxes(Joysticktable[cpt]), SDL_JoystickNumHats(Joysticktable[cpt]));