From 658ad712aea2756b797d1042b3b4171fccdc5ecf Mon Sep 17 00:00:00 2001 From: Tyler Luu Date: Thu, 17 Nov 2011 19:34:29 -0600 Subject: jhead: Add handling for short tags with unknown length Part of the fix for b/5582076 SHORT tags with a variable length need to be places in the data write section. Fixes issue with ISOSpeedRating not being inserted correctly. Change-Id: I9b1810de9102f2e2d63eca1a90547aba7e18a0d7 Signed-off-by: Tyler Luu Signed-off-by: Iliyan Malchev --- exif.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exif.c b/exif.c index 60aec70..4cabb6a 100644 --- a/exif.c +++ b/exif.c @@ -1134,7 +1134,9 @@ static void writeExifTagAndData(int tag, Put32u(Buffer+(*DirIndex) + 8, (*DataWriteIndex)-8); // Pointer char* curElement = strtok((char*)value, ","); int i; - for (i = 0; i < components && curElement != NULL; i++) { + + // (components == -1) Need to handle lists with unknown length too + for (i = 0; ((i < components) || (components == -1)) && curElement != NULL; i++) { #ifdef SUPERDEBUG printf("processing component %s format %s", curElement, formatStr(format)); #endif @@ -1157,6 +1159,11 @@ static void writeExifTagAndData(int tag, Put32u(Buffer+(*DataWriteIndex) + 4, denominator); (*DataWriteIndex) += 8; } + } else if ((components == -1) && ((format == FMT_USHORT) || (format == FMT_SSHORT))) { + // variable components need to go into data write area + value = atoi(curElement); + Put16u(Buffer+(*DataWriteIndex), value); + (*DataWriteIndex) += 4; } else { // TODO: doesn't handle multiple components yet -- if more than one, have to put in data write area. value = atoi(curElement); -- cgit v1.2.3