1
0
Fork 0

Fix #7255: Prevent crashlog corruption by only printing the 32 most recent news messages. (#7542)

pull/7676/head
Charles Pigott 2019-04-25 22:55:16 +01:00 committed by Michael Lutz
parent beba12f9d6
commit e6877d0823
3 changed files with 7 additions and 6 deletions

View File

@ -303,7 +303,7 @@ char *CrashLog::LogGamelog(char *buffer, const char *last) const
} }
/** /**
* Writes any recent news messages to the buffer. * Writes up to 32 recent news messages to the buffer, with the most recent first.
* @param buffer The begin where to write at. * @param buffer The begin where to write at.
* @param last The last position in the buffer to write to. * @param last The last position in the buffer to write to.
* @return the position of the \c '\0' character after the buffer. * @return the position of the \c '\0' character after the buffer.
@ -312,7 +312,8 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const
{ {
buffer += seprintf(buffer, last, "Recent news messages:\n"); buffer += seprintf(buffer, last, "Recent news messages:\n");
for (NewsItem *news = _oldest_news; news != NULL; news = news->next) { int i = 0;
for (NewsItem *news = _latest_news; i < 32 && news != NULL; news = news->prev, i++) {
YearMonthDay ymd; YearMonthDay ymd;
ConvertDateToYMD(news->date, &ymd); ConvertDateToYMD(news->date, &ymd);
buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n", buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",

View File

@ -45,8 +45,8 @@ const NewsItem *_statusbar_news_item = NULL;
static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages static uint MIN_NEWS_AMOUNT = 30; ///< preferred minimum amount of news messages
static uint _total_news = 0; ///< current number of news items static uint _total_news = 0; ///< current number of news items
NewsItem *_oldest_news = NULL; ///< head of news items queue static NewsItem *_oldest_news = NULL; ///< head of news items queue
static NewsItem *_latest_news = NULL; ///< tail of news items queue NewsItem *_latest_news = NULL; ///< tail of news items queue
/** /**
* Forced news item. * Forced news item.
@ -54,7 +54,7 @@ static NewsItem *_latest_news = NULL; ///< tail of news items queue
* If the message being shown was forced by the user, a pointer is stored * If the message being shown was forced by the user, a pointer is stored
* in _forced_news. Otherwise, \a _forced_news variable is NULL. * in _forced_news. Otherwise, \a _forced_news variable is NULL.
*/ */
static const NewsItem *_forced_news = NULL; ///< item the user has asked for static const NewsItem *_forced_news = NULL;
/** Current news item (last item shown regularly). */ /** Current news item (last item shown regularly). */
static const NewsItem *_current_news = NULL; static const NewsItem *_current_news = NULL;

View File

@ -17,6 +17,6 @@
void ShowLastNewsMessage(); void ShowLastNewsMessage();
void ShowMessageHistory(); void ShowMessageHistory();
extern NewsItem *_oldest_news; extern NewsItem *_latest_news;
#endif /* NEWS_GUI_H */ #endif /* NEWS_GUI_H */