summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorUmang Jain <email@uajain.com>2020-09-25 00:06:41 +0530
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-09-29 05:55:00 +0300
commit51bfc823921095b301a6c68e9e59d8cb4e2ffc2d (patch)
treee75d65197181e717cbc48c3d67c9b168060476de /src/android
parentbd542ae775710298cf9ed90fb0a2694c2a41b906 (diff)
android: jpeg: exif: Pad extra byte only for ASCII format in setString()
The EXIF standard states that EXIF_FORMAT_UNDEFINED shall not be terminated with NULL. The patch implements this particular detail and pad one extra byte for EXIF_FORMAT_ASCII to null-terminate strings. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jpeg/exif.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp
index c0dbfcc2..a5674b3d 100644
--- a/src/android/jpeg/exif.cpp
+++ b/src/android/jpeg/exif.cpp
@@ -157,8 +157,9 @@ void Exif::setRational(ExifIfd ifd, ExifTag tag, ExifRational item)
void Exif::setString(ExifIfd ifd, ExifTag tag, ExifFormat format, const std::string &item)
{
- /* Pad 1 extra byte for null-terminated string. */
- size_t length = item.length() + 1;
+ /* Pad 1 extra byte for null-terminated string in ASCII format. */
+ size_t length = format == EXIF_FORMAT_ASCII ?
+ item.length() + 1 : item.length();
ExifEntry *entry = createEntry(ifd, tag, format, length, length);
if (!entry)