]> git.street.me.uk Git - andy/viking.git/blobdiff - src/geotag_exif.c
Retain DOP values when saving to .vik files
[andy/viking.git] / src / geotag_exif.c
index 00e09ee127e9dd37370f8aec1e03767370e3a5a8..4bc4b9708cfb4b59e017c3d2cff2c477747ae488 100644 (file)
@@ -35,7 +35,9 @@
 #include "file.h"
 
 #include <sys/stat.h>
+#ifdef HAVE_UTIME_H
 #include <utime.h>
+#endif
 #include <stdlib.h>
 #include <ctype.h>
 #include <math.h>
@@ -735,7 +737,8 @@ gint a_geotag_write_exif_gps ( const gchar *filename, VikCoord coord, gdouble al
        // Save mtime for later use
        struct stat stat_save;
        if ( no_change_mtime )
-               stat ( filename, &stat_save );
+               if ( stat ( filename, &stat_save ) != 0 )
+                       g_warning ( "%s couldn't read: %s", __FUNCTION__, filename );
 
 #ifdef HAVE_LIBGEXIV2
        GExiv2Metadata *gemd = gexiv2_metadata_new ();
@@ -846,7 +849,10 @@ gint a_geotag_write_exif_gps ( const gchar *filename, VikCoord coord, gdouble al
                (void)stat ( filename, &stat_tmp );
                utb.actime = stat_tmp.st_atime;
                utb.modtime = stat_save.st_mtime;
-               utime ( filename, &utb );
+               // Not security critical, thus potential Time of Check Time of Use race condition is not bad
+               // coverity[toctou]
+               if ( g_utime ( filename, &utb ) != 0 )
+                       g_warning ( "%s couldn't set time on: %s", __FUNCTION__, filename );
        }
 
        return result;