RSP: Fix undefined behavior in RDP_LogDlist

When calling sprintf, source and destination must not overlap
otherwise it is undefined behavior as specified by
C99 standard, 7.19.6.6.

Signed-off-by: Francois Berder <fberder@outlook.fr>
This commit is contained in:
Francois Berder 2019-03-27 09:38:44 +00:00
parent a298011104
commit f2e6199fcb
1 changed files with 9 additions and 3 deletions

View File

@ -182,17 +182,23 @@ void RDP_LogDlist ( void )
}
for (count = 0; count < 0x10; count ++, Pos++ ) {
char tmp[3];
if ((count % 4) != 0 || count == 0) {
sprintf(Hex,"%s %02X",Hex,Mem[Pos]);
sprintf(tmp,"%02X",Mem[Pos]);
strcat(Hex," ");
strcat(Hex,tmp);
} else {
sprintf(Hex,"%s - %02X",Hex,Mem[Pos]);
sprintf(tmp,"%02X",Mem[Pos]);
strcat(Hex," - ");
strcat(Hex,tmp);
}
if (Mem[Pos] < 30 || Mem[Pos] > 127) {
strcat(Ascii,".");
} else {
sprintf(Ascii,"%s%c",Ascii,Mem[Pos]);
sprintf(tmp,"%c",Mem[Pos]);
strcat(Ascii,tmp);
}
}
RDP_Message(" %s %s",Hex, Ascii);