Skip to content

'Remove erroring [tile]entities' treats crash report as a format string #3713

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

Closed
Aaron1011 opened this issue Feb 19, 2017 · 7 comments
Closed
Labels
Bug This request reports or fixes a new or existing bug. Superseded This request has a more updated, more capable, and overall better alternative.

Comments

@Aaron1011
Copy link
Contributor

When the 'remove erroring [tile]entities' option is turned on, tileentity/entioty crash reports are logged using FMLLog.sever. However, this method interprets the message as a format string. If the crash report text happens to contain any format string sequences, the server will crash with an UnknownFormatConversionException - meaning that the original exception is lost.

@diesieben07
Copy link
Contributor

This is far from the only occurrence of this problem. That method should not be using String.format imho.

@LexManos
Copy link
Member

It pops up every now and again, the format is fine.
We just need to filter cases where we want to protect against bad things being formatted twice.

@everseeking
Copy link

Have seen this pop up occasionally, most recently in the FTB Crash subreddit.

Crash report from the thread.

@diesieben07
Copy link
Contributor

The format is (in theory) fine, yes. But if we keep it we need to add escaping at every possible entrypoint. This is just like passing raw data into an SQL query or whatever. In the linked crash the issue is that just an entire crash-report output is shoved through String.format. At some point there will be some invalid formatting codes in there.
I think we should clean up the few places that rely on the String.format and remove it.

@mezz
Copy link
Contributor

mezz commented Jun 4, 2017

Easy solution is just make sure you always give logs a format string:
net.minecraftforge.fml.common.FMLLog.severe("Removing erroring tile entity. Crash report:\n{}", crashreport.func_71502_e());
or skip formatting when there are no data arguments given to the log.

@diesieben07
Copy link
Contributor

You mean "Crash report:\n%s", what you posted is Log4j formatting, which is also applied, in addition to String.format.

@mezz
Copy link
Contributor

mezz commented Jun 4, 2017

Oh ok. I use a log4j logger directly, I didn't know FMLLog had an additional wrapper over it that applies String.format.
I agree with what you said earlier then.

@mezz mezz added Bug This request reports or fixes a new or existing bug. Superseded This request has a more updated, more capable, and overall better alternative. labels Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This request reports or fixes a new or existing bug. Superseded This request has a more updated, more capable, and overall better alternative.
Projects
None yet
Development

No branches or pull requests

5 participants