Handle locations with more than 30 chars for lat/lon.
For some locations more than 30 characters are needed for
representing the lat/lon information and the null character
at the end of the string is overwritten.
This causes the next member of the struct to be included when
reading the string which causes a NumberFormatException in
convertRationalLatLonToFloat() in ExifInterface.java and a
0f is returned.
The size of GpsLongRaw/GpsLatRaw is increased to 72 in
jhead.h since this is the maximum length of the string,
i.e. 11 * 6 + 3(‘/’) + 2(’,’) + 1(\0) = 72 . The length of
each component is 11 since it is a 32 bit signed number.
In gpsinfo.c strncpy will copy at most 71 characters since
this is the maximum length of the string.
Change-Id: Id24995ed08aa277681d9648054ebddc2c275f6b6
diff --git a/gpsinfo.c b/gpsinfo.c
index 896ad28..2661e52 100644
--- a/gpsinfo.c
+++ b/gpsinfo.c
@@ -187,7 +187,7 @@
switch(Tag){
char FmtString[21];
- char TempString[50];
+ char TempString[MAX_BUF_SIZE];
double Values[3];
case TAG_GPS_LAT_REF:
@@ -237,9 +237,9 @@
Get32s(8+(char*)ValuePtr), Get32s(12+(char*)ValuePtr),
Get32s(16+(char*)ValuePtr), Get32s(20+(char*)ValuePtr));
if (Tag == TAG_GPS_LAT){
- strncpy(ImageInfo.GpsLatRaw, TempString, 31);
+ strncpy(ImageInfo.GpsLatRaw, TempString, MAX_BUF_SIZE);
}else{
- strncpy(ImageInfo.GpsLongRaw, TempString, 31);
+ strncpy(ImageInfo.GpsLongRaw, TempString, MAX_BUF_SIZE);
}
break;