Skip to content

Commit

Permalink
Fixed bug 4968 - NULL passed to memcpy in WriteProprietary in SDL_hid…
Browse files Browse the repository at this point in the history
…api_switch.c

meyraud705

In SDL_hidapi_switch.c

line 443: Function BTrySetupUSB call WriteProprietary with pBuf=NULL and ucLen=0
line 376: WriteProprietary check its input (!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData): ucLen is 0 so it passes
line 382: WriteProprietary call memcpy with pBuf=NULL
  • Loading branch information
slouken committed Feb 7, 2020
1 parent dd0ebfd commit 833f76a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/joystick/hidapi/SDL_hidapi_switch.c
Expand Up @@ -391,7 +391,9 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta

packet.ucPacketType = k_eSwitchOutputReportIDs_Proprietary;
packet.ucProprietaryID = ucCommand;
SDL_memcpy(packet.rgucProprietaryData, pBuf, ucLen);
if (pBuf) {
SDL_memcpy(packet.rgucProprietaryData, pBuf, ucLen);
}

if (!WritePacket(ctx, &packet, sizeof(packet))) {
continue;
Expand Down

0 comments on commit 833f76a

Please sign in to comment.