Linus Torvalds e964f533ff Fix 32-bit overflow in Divesoft Freedom time handling
Commit 31fb2e4c62ab ("Avoid possible sign extension") handled the
problem when a "unsigned char" is shifted 24 bits left, and becomes a
"signed int".  By casting the result to uint32_t, that signed case won't
happen.

However, there were two bugs in that fix.

The first is the comment.  It's not that "timestamp_t" is signed that is
the problem.  No, the problem is inherent in the C expression

    (ptr[11] << 24)

where "ptr[11]" is an unsigned char.  In C arithmetic, unsigned char is
implicitly type-expanded to "int", so while it has a value between
0..255, when you shift it left by 24, you can get a *negative* "int" as
a result.

So it's actually "ptr[11]" that should have been cast to "unsigned", but
it so happens that you can do all the shifting and adding in "int", and
then cast the end result to "uint32_t" and you'll get the same value.
But at no point did "timestamp_t" matter.

The other bug was pre-existing and just not fixed.  When the code does
the "+ 946684800" (to turn the timestamp to be seconds from the start of
2000, into seconds since the "unix epoch", ie 1970) that arithmetic is
now done in that "uint32_t" (and used to be done in "int").

Which means that the addition can overflow in 32 bits *before* it is
cast to timestamp_t (which is 64 bits).

Admittedly that 32-bit overflow happens a bit later than the sign bit
gets set, but if we're worried aboout overflows, let's just do this
right.

In other words, we have a 32-bit unsigned offset since Jan 1, 2000, and
for the full range we need to do the epoch correction in 32 bits.
Because otherwise you fail in the year 2106 (32-bit unsigned unix epoch
time limit), even though the 32-bit seconds *should* work all the way
until the year 2136.

Of course, I'll be rather surprised if people still use the Divesoft
Freedom in the year 2106.  Or rather, I won't be surprised, because I'll
be dead.

But if we think that the signed problem matters (in the year 2068), then
dammit, we can extend it another 30 years.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-03 00:05:40 -04:00
2013-12-29 10:34:12 -08:00
2015-09-23 12:25:14 -07:00
2015-08-31 15:49:09 -07:00
2015-09-18 10:04:50 -07:00
2015-10-02 17:30:21 -04:00
2014-10-29 09:05:15 -07:00
2015-09-09 17:29:13 -07:00
2015-10-01 21:12:31 -04:00
2014-02-27 20:09:57 -08:00
2015-10-02 21:25:17 -04:00
2015-08-31 15:12:18 -07:00
2015-09-13 15:27:54 -07:00
2014-11-16 20:50:16 +00:00
2013-11-29 11:27:41 -08:00
2015-01-29 13:37:11 -08:00
2015-10-01 21:37:32 -04:00
2015-09-02 18:33:39 -07:00
2014-11-13 11:58:59 -08:00
2015-09-09 17:26:54 -07:00
2015-10-02 17:41:02 -04:00
2015-08-23 07:28:52 -07:00
2015-09-20 15:10:31 -07:00
2015-07-22 19:09:49 +03:00
2015-09-19 07:24:42 -07:00
2015-01-15 19:48:11 -08:00
2013-01-22 22:25:03 -08:00
2015-09-09 21:33:49 -07:00
2014-03-05 13:02:23 -08:00
2014-02-27 20:09:57 -08:00
2014-02-27 20:09:57 -08:00
2014-02-27 20:09:57 -08:00
2014-11-18 13:15:43 +00:00
2014-02-11 12:37:01 -08:00
2015-06-17 05:27:18 -07:00
2014-05-22 11:40:22 -07:00
2014-02-06 11:29:23 -08:00

This is the README file for Subsurface 4.5 Beta 2

Please check the ReleaseNotes.txt for details about new features and
changes since Subsurface 4.5 Beta 1, Subsurface 4.4.2 (and earlier
versions).

Subsurface can be found at http://subsurface-divelog.org

Our user forum is at http://subsurface-divelog.org/user-forum/
We also try to respond to questions in the ScubaBoard.com dive software
forum at http://www.scubaboard.com/forums/dive-software/

Report bugs and issues at http://trac.subsurface-divelog.org

License: GPLv2

You can get the sources to the latest development version from the git
repository:

git clone git://git.subsurface-divelog.org/subsurface.git .

You can also browse the sources via gitweb at the same site.

If you want the latest release (instead of the bleeding edge
development version) you can either get this via git or the release tar
ball. After cloning run the following command:

git checkout v4.4.2  (or whatever the last release is)

or download a tar ball from:

http://subsurface-divelog.org/downloads/Subsurface-4.4.2.tgz

Detailed build instructions can be found in the INSTALL file.

Basic Usage:
============

Install and start from the desktop, or you can run it locally from the
build directory:

On Linux:

$ ./subsurface

On Mac:

$ open Subsurface.app

Native builds on Windows are not really supported (the official Windows
installers are both cross-built on Linux).

You can give a data file as command line argument, or (once you have
set this up in the Preferences) Subsurface picks a default file for
you when started from the desktop or without an argument.

If you have a dive computer supported by libdivecomputer, you can just
select "Import from Divecomputer" from the "Import" menu, select which
dive computer you have (and where it is connected if you need to), and
hit "OK".

The latest list of supported dive computers can be found in the file
SupportedDivecomputers.txt.

Much more detailed end user instructions can be found from inside
Subsurface by selecting Help (typically F1). When building from source
this is also available as Documentation/user-manual.html. The
documentation for the latest release is also available on-line
http://subsurface-divelog.org/documentation/


Contributing:
=============

There is a mailing list for developers: subsurface@subsurface-divelog.org
Go to http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
to subscribe.

If you want to contribute code, please either send signed-off patches or
a pull request with signed-off commits.  If you don't sign off on them,
we will not accept them. This means adding a line that says
"Signed-off-by: Name <email>" at the end of each commit, indicating that
you wrote the code and have the right to pass it on as an open source
patch.

See: http://developercertificate.org/

Also, please write good git commit messages.  A good commit message
looks like this:

	Header line: explain the commit in one line (use the imperative)

	Body of commit message is a few lines of text, explaining things
	in more detail, possibly giving some background about the issue
	being fixed, etc etc.

	The body of the commit message can be several paragraphs, and
	please do proper word-wrap and keep columns shorter than about
	74 characters or so. That way "git log" will show things
	nicely even when it's indented.

	Make sure you explain your solution and why you're doing what you're
	doing, as opposed to describing what you're doing. Reviewers and your
	future self can read the patch, but might not understand why a
	particular solution was implemented.

	Reported-by: whoever-reported-it
	Signed-off-by: Your Name <youremail@yourhost.com>

where that header line really should be meaningful, and really should be
just one line.  That header line is what is shown by tools like gitk and
shortlog, and should summarize the change in one readable line of text,
independently of the longer explanation. Please use verbs in the
imperative in the commit message, as in "Fix bug that...", "Add
file/feature ...", or "Make Subsurface..."


A bit of Subsurface history:
============================

In fall of 2011, when a forced lull in kernel development gave him an
opportunity to start on a new endeavor, Linus Torvalds decided to tackle
his frustration with the lack of decent divelog software on Linux.

Subsurface is the result of the work of him and a team of developers since
then. It now supports Linux, Windows and MacOS and allows data import from
a large number of dive computers and several existing divelog programs. It
provides advanced visualization of the key information provided by a
modern dive computer and allows the user to track a wide variety of data
about their diving.

In fall of 2012 Dirk Hohndel took over as maintainer of Subsurface.
Description
No description provided
Readme 166 MiB
Languages
C++ 74.4%
XSLT 6%
C 5.9%
QML 5.6%
Shell 2.8%
Other 5.1%