summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Kun2 <kun2.wang@sonyericsson.com>2010-11-24 13:27:17 +0100
committerJohan Redestig <johan.redestig@sonymobile.com>2012-06-05 10:25:33 +0200
commit2bfc190bd3be7e1b91fe3d7ca49412ebf0f5ceee (patch)
tree20f78c1c70b33019fcc73b60b7595ad5e36fd0b8
parent754078052c687f6721536009c816644c73e4f145 (diff)
downloadjhead-2bfc190bd3be7e1b91fe3d7ca49412ebf0f5ceee.tar.gz
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
-rw-r--r--gpsinfo.c6
-rw-r--r--jhead.h9
2 files changed, 10 insertions, 5 deletions
diff --git a/gpsinfo.c b/gpsinfo.c
index 896ad28..2661e52 100644
--- a/gpsinfo.c
+++ b/gpsinfo.c
@@ -187,7 +187,7 @@ void ProcessGpsInfo(unsigned char * DirStart, int ByteCountUnused, unsigned char
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 @@ void ProcessGpsInfo(unsigned char * DirStart, int ByteCountUnused, unsigned char
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;
diff --git a/jhead.h b/jhead.h
index 4347fe8..a73c578 100644
--- a/jhead.h
+++ b/jhead.h
@@ -61,6 +61,11 @@ extern int DumpExifMap;
#define MAX_DATE_COPIES 10
+// Buffer size must large enough to hold maximum location string
+// containing six signed integers plus delimeters and terminator,
+// i.e.: 11 * 6 + 3(‘/’) + 2(’,’) + 1(\0) = 72
+#define MAX_BUF_SIZE 72
+
typedef struct {
uint32_t num;
uint32_t denom;
@@ -114,10 +119,10 @@ typedef struct {
int GpsInfoPresent;
char GpsLat[31];
- char GpsLatRaw[31];
+ char GpsLatRaw[MAX_BUF_SIZE];
char GpsLatRef[2];
char GpsLong[31];
- char GpsLongRaw[31];
+ char GpsLongRaw[MAX_BUF_SIZE];
char GpsLongRef[2];
char GpsAlt[20];
rat_t GpsAltRaw;