Skip to content

Commit

Permalink
[bugfix] Restore overflowed memory copy
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtreetech authored Aug 28, 2019
1 parent a3a5686 commit 7eb0333
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions STM32F1/cores/maple/libmaple/usb/usb_lib/usb_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,22 @@ void PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes)
u32 n = (wNBytes + 1) >> 1;/* /2*/
u32 i;
u32 *pdwVal;
u8 *pbStartUsrBuf = pbUsrBuf;
u8 endVal;
if(wNBytes & 0x0001)
{
endVal = pbStartUsrBuf[wNBytes];
}
pdwVal = (u32 *)(wPMABufAddr * 2 + PMAAddr);
for (i = n; i != 0; i--)
{
*(u16*)pbUsrBuf++ = *pdwVal++;
pbUsrBuf++;
}
if(wNBytes & 1)
{
pbStartUsrBuf[wNBytes] = endVal;
}
}

/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

0 comments on commit 7eb0333

Please sign in to comment.