8301132: Test update for deprecated sprintf in Xcode 14

Reviewed-by: mikael
This commit is contained in:
Xue-Lei Andrew Fan 2023-01-27 19:01:01 +00:00
parent 7f05d57a87
commit 9c4bc2c395
2 changed files with 8 additions and 6 deletions

View File

@ -61,8 +61,9 @@ int main(int argc, char**argv) {
fprintf(stderr, "Usage: %s jvm-path classpath class\n", argv[0]);
return -1;
}
cp_prop = (char*)malloc(strlen(CP_PROP)+strlen(argv[2]) +1);
sprintf(cp_prop, "%s%s", CP_PROP, argv[2]);
size_t propLen = strlen(CP_PROP) + strlen(argv[2]) + 1;
cp_prop = (char*)malloc(propLen);
snprintf(cp_prop, propLen, "%s%s", CP_PROP, argv[2]);
options[0].optionString = cp_prop;
vm_args.version = 0x00010002;

View File

@ -99,12 +99,13 @@ static char *getTextualSid(SID* sid) {
}
// S-SID_REVISION
sprintf(name, "S-%lu-", SID_REVISION );
snprintf(name, len, "S-%lu-", SID_REVISION );
// Identifier authority
if ((sia->Value[0] != 0) || (sia->Value[1] != 0))
{
sprintf(name + strlen(name), "0x%02hx%02hx%02hx%02hx%02hx%02hx",
snprintf(name + strlen(name), len - strlen(name),
"0x%02hx%02hx%02hx%02hx%02hx%02hx",
(USHORT)sia->Value[0],
(USHORT)sia->Value[1],
(USHORT)sia->Value[2],
@ -114,7 +115,7 @@ static char *getTextualSid(SID* sid) {
}
else
{
sprintf(name + strlen(name), "%lu",
snprintf(name + strlen(name), len - strlen(name), "%lu",
(ULONG)(sia->Value[5] ) +
(ULONG)(sia->Value[4] << 8) +
(ULONG)(sia->Value[3] << 16) +
@ -123,7 +124,7 @@ static char *getTextualSid(SID* sid) {
// finally, the sub-authorities
for (i=0 ; i<count; i++) {
sprintf(name + strlen(name), "-%lu",
snprintf(name + strlen(name), len - strlen(name), "-%lu",
*GetSidSubAuthority(sid, i) );
}