From patchwork Thu Sep 24 18:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9796 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5FE78C3B5B for ; Thu, 24 Sep 2020 18:37:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B3EC62F4F; Thu, 24 Sep 2020 20:37:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="OuYuaTmK"; dkim-atps=neutral Received: from mail.uajain.com (static.126.159.217.95.clients.your-server.de [95.217.159.126]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CC3662F4F for ; Thu, 24 Sep 2020 20:36:58 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1600972618; bh=v+T2p+UETjllPjGohbyeiUXogk8kOItTOBlRt9UXl50=; h=From:To:Cc:Subject:In-Reply-To:References; b=OuYuaTmKh33wP0DXmEfeGU1SeOpPFQ65K+4z1F2wba9qERVP32a5rg2zJD5SGgmxy aZkT8iZEYksVY4HFHnDPQkKYeNVATbD0HPWMkm9G9q+Wa9N6mPJrZ+np2n+HAGHmVS RzjYn3wH5l0HXkkqVHgEe/rv6Df1634ibJggHumuesRe/mDSlro8r1oSS6omA/Mf5s gSq0QzUhdgr9wycAOtHpsR3CS6r36uuqGOYjUI5DfdJ9Pp3n6bMBQKcNpox1dn1m2t 9bhinAxO5a6yC14fis0K+JoXzx4hJhRHFSffIKDn/bs6lOfiE25tpBgaPsFIBvgTfh r/wgZcIxX+xJA== To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Sep 2020 00:06:41 +0530 Message-Id: <20200924183642.7674-2-email@uajain.com> In-Reply-To: <20200924183642.7674-1-email@uajain.com> References: <20200924183642.7674-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] android: jpeg: exif: Pad extra byte only for ASCII format in setString() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart --- src/android/jpeg/exif.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index c0dbfcc..a5674b3 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)