diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-12-12 16:12:04 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-12 16:29:06 -0800 |
commit | 89a58e23e095c50dc844cbbed577c989cf801e32 (patch) | |
tree | 0d119eef84d5a52518c4685fedde0b57e90f41d4 /dives | |
parent | 007aa79fd711395dd2d747ca1ba7a6e05820d1c1 (diff) | |
download | subsurface-89a58e23e095c50dc844cbbed577c989cf801e32.tar.gz |
Correctly parse multiple tags in the divelog
The old parsing code overwrote the first comma with a '\0' and then
checked the index against the length of the buffer - which was changed by
replacing the ',' with the '\0'.
This means that since commit 78acf20848c0 ("Don't crash on loading tags
longer than 127 chars") Subsurface has potentially damaged / lost data in
dive files!
Added a test dive that shows the issue if opened by a Subsurface version
after the commit mentioned above but before this commit.
Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dives')
-rw-r--r-- | dives/test29.xml | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/dives/test29.xml b/dives/test29.xml new file mode 100644 index 000000000..9fb40a61d --- /dev/null +++ b/dives/test29.xml @@ -0,0 +1,62 @@ +<divelog program='subsurface' version='2'> +<settings> +</settings> +<dives> +<dive number='29' tags='boat, wreck' date='2011-12-13' time='06:35:00' duration='30:00 min'> + <location>irrelevant dive location</location> + <notes>This is a dive that has two tags, boat and wreck</notes> + <divecomputer model='Model Product' deviceid='e04d0248' diveid='00000002'> + <depth max='20.1 m' mean='18.293 m' /> + <temperature water='20.0 C' /> + <sample time='0:06 min' depth='1.86 m' temp='20.0 C' ndl='99:00 min' /> + <sample time='1:00 min' depth='20.1 m' /> + <sample time='27:00 min' depth='20.1 m' /> + <sample time='28:00 min' depth='3.0 m' /> + <sample time='29:00 min' depth='3.0 m' /> + <sample time='30:00 min' depth='0.3 m' /> + </divecomputer> +</dive> +<dive number='30' tags='' date='2011-12-13' time='07:35:00' duration='30:00 min'> + <location>irrelevant dive location</location> + <notes>This is a dive that has an empty tags property in the XML file</notes> + <divecomputer model='Model Product' deviceid='e04d0248' diveid='00000002'> + <depth max='20.1 m' mean='18.293 m' /> + <temperature water='20.0 C' /> + <sample time='0:06 min' depth='1.86 m' temp='20.0 C' ndl='99:00 min' /> + <sample time='1:00 min' depth='20.1 m' /> + <sample time='27:00 min' depth='20.1 m' /> + <sample time='28:00 min' depth='3.0 m' /> + <sample time='29:00 min' depth='3.0 m' /> + <sample time='30:00 min' depth='0.3 m' /> + </divecomputer> +</dive> +<dive number='31' tags=',' date='2011-12-13' time='08:35:00' duration='30:00 min'> + <location>irrelevant dive location</location> + <notes>This is a dive that has a tags property with just a comma in the XML file</notes> + <divecomputer model='Model Product' deviceid='e04d0248' diveid='00000002'> + <depth max='20.1 m' mean='18.293 m' /> + <temperature water='20.0 C' /> + <sample time='0:06 min' depth='1.86 m' temp='20.0 C' ndl='99:00 min' /> + <sample time='1:00 min' depth='20.1 m' /> + <sample time='27:00 min' depth='20.1 m' /> + <sample time='28:00 min' depth='3.0 m' /> + <sample time='29:00 min' depth='3.0 m' /> + <sample time='30:00 min' depth='0.3 m' /> + </divecomputer> +</dive> +<dive number='32' tags='a, boat' date='2011-12-13' time='09:35:00' duration='30:00 min'> + <location>irrelevant dive location</location> + <notes>This is a dive that has a single letter tag 'a' (plus the boat tag)</notes> + <divecomputer model='Model Product' deviceid='e04d0248' diveid='00000002'> + <depth max='20.1 m' mean='18.293 m' /> + <temperature water='20.0 C' /> + <sample time='0:06 min' depth='1.86 m' temp='20.0 C' ndl='99:00 min' /> + <sample time='1:00 min' depth='20.1 m' /> + <sample time='27:00 min' depth='20.1 m' /> + <sample time='28:00 min' depth='3.0 m' /> + <sample time='29:00 min' depth='3.0 m' /> + <sample time='30:00 min' depth='0.3 m' /> + </divecomputer> +</dive> +</dives> +</divelog> |