Mercurial > hg > forks > geeqie
comparison src/exif-common.c @ 2811:579554d940e7
Bug fix: Crash when GPSInfo contains illegal characters
If Exif.GPSInfo contains unexpected characters, it can cause a seg.
fault when passed to atof().
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Fri, 10 Aug 2018 10:06:19 +0100 |
parents | 7061c1eacc20 |
children | 0c4659cd6d32 |
comparison
equal
deleted
inserted
replaced
2810:8438d30abd31 | 2811:579554d940e7 |
---|---|
810 text_latitude = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLatitude"); | 810 text_latitude = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLatitude"); |
811 text_longitude = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLongitude"); | 811 text_longitude = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLongitude"); |
812 text_latitude_ref = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLatitudeRef"); | 812 text_latitude_ref = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLatitudeRef"); |
813 text_longitude_ref = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLongitudeRef"); | 813 text_longitude_ref = exif_get_data_as_text(exif, "Exif.GPSInfo.GPSLongitudeRef"); |
814 | 814 |
815 if (text_latitude && text_longitude && text_latitude_ref && | 815 if ((text_latitude && g_strrstr(text_latitude, "deg")) && |
816 text_longitude_ref) | 816 (text_longitude && g_strrstr(text_longitude, "deg")) && |
817 ( | |
818 (text_latitude_ref && g_strrstr(text_latitude_ref, "N")) || | |
819 (text_latitude_ref && g_strrstr(text_latitude_ref, "S")) | |
820 ) && | |
821 ( | |
822 (text_longitude_ref && g_strrstr(text_longitude_ref, "E")) || | |
823 (text_longitude_ref && g_strrstr(text_longitude_ref, "W")) | |
824 ) | |
825 ) | |
817 { | 826 { |
818 lat_deg = strtok(text_latitude, "deg'"); | 827 lat_deg = strtok(text_latitude, "deg'"); |
819 lat_min = strtok(NULL, "deg'"); | 828 lat_min = strtok(NULL, "deg'"); |
820 latitude = atof(lat_deg) + atof(lat_min) / 60; | 829 latitude = atof(lat_deg) + atof(lat_min) / 60; |
821 if (g_strcmp0(text_latitude_ref, "South") == 0) | 830 if (g_strcmp0(text_latitude_ref, "South") == 0) |