Merge pull request #1600 from francois-berder/master

Fix undefined behavior related to sprintf
This commit is contained in:
zilmar 2019-03-27 21:59:03 +10:30 committed by GitHub
commit 693925f340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -643,7 +643,9 @@ void CPifRam::LogControllerPakData(const char * Description)
}
else
{
sprintf(Addon, "%s%c", Addon, PIF_Ram[(count << 2) + count2]);
char tmp[2];
sprintf(tmp, "%c", PIF_Ram[(count << 2) + count2]);
strcat(Addon, tmp);
}
}
strcat(AsciiData, Addon);

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);