diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/libexif/ExifParse.cpp | 50 | ||||
-rw-r--r-- | lib/libexif/libexif.h | 6 |
2 files changed, 43 insertions, 13 deletions
diff --git a/lib/libexif/ExifParse.cpp b/lib/libexif/ExifParse.cpp index e194bdd90f..e7be3676a4 100755 --- a/lib/libexif/ExifParse.cpp +++ b/lib/libexif/ExifParse.cpp @@ -421,8 +421,26 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, m_ExifInfo->Description[length] = '\0'; break; } - case TAG_MAKE: strncpy(m_ExifInfo->CameraMake, (char *)ValuePtr, 32); break; - case TAG_MODEL: strncpy(m_ExifInfo->CameraModel, (char *)ValuePtr, 40); break; + case TAG_MAKE: + { + int space = sizeof(m_ExifInfo->CameraMake); + if (space > 0) + { + strncpy(m_ExifInfo->CameraMake, (char *)ValuePtr, space - 1); + m_ExifInfo->CameraMake[space] = '\0'; + } + break; + } + case TAG_MODEL: + { + int space = sizeof(m_ExifInfo->CameraModel); + if (space > 0) + { + strncpy(m_ExifInfo->CameraModel, (char *)ValuePtr, space - 1); + m_ExifInfo->CameraModel[space] = '\0'; + } + break; + } // case TAG_SOFTWARE: strncpy(m_ExifInfo->Software, ValuePtr, 5); break; case TAG_FOCALPLANEXRES: m_FocalPlaneXRes = ConvertAnyFormat(ValuePtr, Format); break; case TAG_THUMBNAIL_OFFSET: m_ExifInfo->ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format); break; @@ -433,22 +451,34 @@ void CExifParse::ProcessDir(const unsigned char* const DirStart, break; case TAG_DATETIME_ORIGINAL: - // If we get a DATETIME_ORIGINAL, we use that one. - strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, 20); - m_DateFound = true; - break; + { + int space = sizeof(m_ExifInfo->DateTime); + if (space > 0) + { + strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, space - 1); + m_ExifInfo->DateTime[space] = '\0'; + // If we get a DATETIME_ORIGINAL, we use that one. + m_DateFound = true; + } + break; + } case TAG_DATETIME_DIGITIZED: case TAG_DATETIME: + { if (m_DateFound == false) { // If we don't already have a DATETIME_ORIGINAL, use whatever // time fields we may have. - strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, 20); -// LocaliseDate(); + int space = sizeof(m_ExifInfo->DateTime); + if (space > 0) + { + strncpy(m_ExifInfo->DateTime, (char *)ValuePtr, space - 1); + m_ExifInfo->DateTime[space] = '\0'; + } } - break; - + break; + } case TAG_USERCOMMENT: { // The UserComment allows comments without the charset limitations of ImageDescription. diff --git a/lib/libexif/libexif.h b/lib/libexif/libexif.h index be2d37d1a6..aa8da07553 100644 --- a/lib/libexif/libexif.h +++ b/lib/libexif/libexif.h @@ -85,9 +85,9 @@ typedef struct { #define MAX_DATE_COPIES 10 typedef struct { - char CameraMake [32]; - char CameraModel [40]; - char DateTime [20]; + char CameraMake [33]; + char CameraModel [41]; + char DateTime [21]; int Height, Width; int Orientation; int IsColor; |