[gpsbabel] Fix Garmin .fit file handling (RHBZ 989851).

corsepiu corsepiu at fedoraproject.org
Wed Jul 31 07:43:14 UTC 2013


commit b0af2d3ee676e4885c6e128bc712dd9a765bd474
Author: Conrad Meyer <cse.cem at gmail.com>
Date:   Tue Jul 30 23:04:01 2013 -0700

    Fix Garmin .fit file handling (RHBZ 989851).

 gpsbabel-1.4.4-bug989851.patch |   50 ++++++++++++++++++++++++++++++++++++++++
 gpsbabel.spec                  |   12 ++++++++-
 2 files changed, 61 insertions(+), 1 deletions(-)
---
diff --git a/gpsbabel-1.4.4-bug989851.patch b/gpsbabel-1.4.4-bug989851.patch
new file mode 100644
index 0000000..138d10c
--- /dev/null
+++ b/gpsbabel-1.4.4-bug989851.patch
@@ -0,0 +1,50 @@
+diff -urN -U20 gpsbabel-1.4.4.orig/garmin_fit.c gpsbabel-1.4.4/garmin_fit.c
+--- gpsbabel-1.4.4.orig/garmin_fit.c	2012-05-14 07:59:17.000000000 -0700
++++ gpsbabel-1.4.4/garmin_fit.c	2013-07-30 22:59:03.675857670 -0700
+@@ -96,40 +96,46 @@
+           ver >> 4, ver & 0xf);
+   if (global_opts.debug_level >= 1) {
+     debug_print(1,"%s: protocol version=%d\n", MYNAME, ver);
+   }
+ 
+   // profile version
+   ver = gbfgetuint16(fin);
+   // data length
+   fit_data.len = gbfgetuint32(fin);
+   // File signature
+   is_fatal(gbfread(sig, 4, 1, fin) != 1,
+            MYNAME ": Unexpected end of file\n");
+   if (sig[0] != '.' || sig[1] != 'F' || sig[2] != 'I' || sig[3] != 'T') {
+     fatal(MYNAME ": .FIT signature missing\n");
+   }
+ 
+   if (global_opts.debug_level >= 1) {
+     debug_print(1,"%s: profile version=%d\n", MYNAME, ver);
+     debug_print(1,"%s: fit_data.len=%d\n", MYNAME, fit_data.len);
+   }
++
++  if (len > 12) {
++    is_fatal(len != 14, MYNAME ": .FIT header with unrecognized size\n");
++    // Unused according to Ingo Arndt
++    gbfgetuint16(fin);
++  }
+ }
+ 
+ static gbuint8
+ fit_getuint8(void)
+ {
+   int val;
+ 
+   if (fit_data.len == 0) {
+     // fail gracefully for GARMIN Edge 800 with newest firmware, seems to write a wrong record length
+     // for the last record.
+     //fatal(MYNAME ": record truncated: fit_data.len=0\n");
+     if (global_opts.debug_level >= 1) {
+       warning("%s: record truncated: fit_data.len=0\n", MYNAME);
+     }
+     return 0;
+   }
+   val = gbfgetc(fin);
+   if (val == EOF) {
+     fatal(MYNAME ": unexpected end of file with fit_data.len=%d\n",fit_data.len);
+   }
diff --git a/gpsbabel.spec b/gpsbabel.spec
index 8e8d39b..72983c1 100644
--- a/gpsbabel.spec
+++ b/gpsbabel.spec
@@ -1,6 +1,6 @@
 Name:          gpsbabel
 Version:       1.4.4
-Release:       3%{?dist}
+Release:       4%{?dist}
 Summary:       A tool to convert between various formats used by GPS devices
 
 Group:         Applications/Text
@@ -36,6 +36,10 @@ Patch23:       gpsbabel-1.4.3-nosolicitation.patch
 Patch24:       gpsbabel-1.4.3-gzip.diff
 # Add aarch64 (RHBZ 925480)
 Patch25:       gpsbabel-1.4.4-config.patch
+# Fix header parsing bug in (some) Garmin .fit files.
+# Fixed in upstream SVN, but ETA on next release is 1+ years and upstream does
+# not want to issue a bugfix release.
+Patch26:       gpsbabel-1.4.4-bug989851.patch
 
 BuildRoot:     %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 
@@ -90,6 +94,9 @@ rm -rf shapelib
 %patch23 -p1
 %patch24 -p1
 
+# Garmin .fit bug fix (# 989851)
+%patch26 -p1
+
 # Get rid of bundled zlib
 # configure --with-zlib=system is not enough,
 # building still accesses bundled zlib headers
@@ -180,6 +187,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %endif
 
 %changelog
+* Tue Jul 30 2013 Conrad Meyer <cemeyer at uw.edu> - 1.4.4-4
+- Fix Garmin .fit file handling (RHBZ 989851).
+
 * Sun Mar 24 2013 Ralf Corsépius <corsepiu at fedoraproject.org> - 1.4.4-3
 - Add aarch64 (RHBZ 925480).
 


More information about the scm-commits mailing list