hrev54149 adds 1 changeset to branch 'master'
old head: d8d403ef5ddbab1f79e1033c950765fcb8136c06
new head: 9670db20dd1efad9cd585d6770adf1493376b2ba
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=9670db20dd1e+%5Ed8d403ef5ddb
----------------------------------------------------------------------------
9670db20dd1e: Tracker: add some time_t overflow checks in StatusWindow
Don't pretend file copies will end in 1901, that's obviously wrong.
Helps with #11176, but we should really not use time_t here, or make it
64bit.
Fun fact: we're now closer to the end of the UNIX epoch than to the creation
of Haiku!
Change-Id: I64acc5ab29fb778fe3034c65b5a8418951d30505
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2608
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
[ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev54149
Commit: 9670db20dd1efad9cd585d6770adf1493376b2ba
URL: https://git.haiku-os.org/haiku/commit/?id=9670db20dd1e
Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date: Fri May 8 18:28:49 2020 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Fri May 8 22:07:08 2020 UTC
Ticket: https://dev.haiku-os.org/ticket/11176
----------------------------------------------------------------------------
1 file changed, 19 insertions(+), 14 deletions(-)
src/kits/tracker/StatusWindow.cpp | 33 +++++++++++++++++++--------------
----------------------------------------------------------------------------
diff --git a/src/kits/tracker/StatusWindow.cpp
b/src/kits/tracker/StatusWindow.cpp
index 3fdf4f5157..420549981a 100644
--- a/src/kits/tracker/StatusWindow.cpp
+++ b/src/kits/tracker/StatusWindow.cpp
@@ -794,26 +794,31 @@ BStatusView::_TimeStatusString(float availableSpace,
float* _width)
double secondsRemaining = (fTotalSize - fSizeProcessed)
/ totalBytesPerSecond;
time_t now = (time_t)real_time_clock();
- time_t finishTime = (time_t)(now + secondsRemaining);
- char timeText[32];
- if (finishTime - now > kSecondsPerDay) {
- BDateTimeFormat().Format(timeText, sizeof(timeText), finishTime,
- B_MEDIUM_DATE_FORMAT, B_MEDIUM_TIME_FORMAT);
+ BString string;
+ if (secondsRemaining < 0 || (sizeof(time_t) == 4
+ && now + secondsRemaining > INT32_MAX)) {
+ string = B_TRANSLATE("Finish: after several years");
} else {
- BTimeFormat().Format(timeText, sizeof(timeText), finishTime,
- B_MEDIUM_TIME_FORMAT);
- }
+ char timeText[32];
+ time_t finishTime = (time_t)(now + secondsRemaining);
- BString string(_FullTimeRemainingString(now, finishTime, timeText));
- float width = StringWidth(string.String());
- if (width > availableSpace) {
- string.SetTo(_ShortTimeRemainingString(timeText));
- width = StringWidth(string.String());
+ if (finishTime - now > kSecondsPerDay) {
+ BDateTimeFormat().Format(timeText, sizeof(timeText),
finishTime,
+ B_MEDIUM_DATE_FORMAT,
B_MEDIUM_TIME_FORMAT);
+ } else {
+ BTimeFormat().Format(timeText, sizeof(timeText),
finishTime,
+ B_MEDIUM_TIME_FORMAT);
+ }
+ string = _FullTimeRemainingString(now, finishTime, timeText);
+ float width = StringWidth(string.String());
+ if (width > availableSpace) {
+ string.SetTo(_ShortTimeRemainingString(timeText));
+ }
}
if (_width != NULL)
- *_width = width;
+ *_width = StringWidth(string.String());
return string;
}