Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cellRtc: fix out of bounds write #13459

Merged
merged 4 commits into from
Mar 1, 2023
Merged

cellRtc: fix out of bounds write #13459

merged 4 commits into from
Mar 1, 2023

Conversation

Megamouse
Copy link
Contributor

@Megamouse Megamouse commented Feb 27, 2023

Turns out you should listen to warnings once in a while...
sprintf actually wrote more than 3 characters into the microDigits buffer !!!

	CellRtcDateTime date_time{};
	date_time.microsecond = 123456;

	std::array<char, 3> microDigits{};
	snprintf(microDigits.data(), microDigits.size(), "%02u", u32{date_time.microsecond});

	char microDigits2[3];
	sprintf(microDigits2, "%02u", u32{date_time.microsecond});

	sys_log.error("sprintf='%s'", microDigits2);
	sys_log.error("snprintf='%s'", microDigits.data());
E SYS: sprintf='123456'
E SYS: snprintf='12'

Turns out you should listen to warnings once in a while...
sprint actually wrote more than 3 characters into the microDigits buffer !!!
@Megamouse Megamouse changed the title cellRtx: fix out of bounds write cellRtc: fix out of bounds write Feb 27, 2023
@Megamouse Megamouse merged commit 73b5b9d into RPCS3:master Mar 1, 2023
@Megamouse Megamouse deleted the sprintf branch March 2, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant