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>
This commit is contained in:
committed by
Laurent Pinchart
parent
bd542ae775
commit
51bfc82392
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user