jpeg: fix non null-terminated string issue
authorLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Thu, 15 Jan 2015 13:23:36 +0000 (11:23 -0200)
committerLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Thu, 15 Jan 2015 13:23:36 +0000 (11:23 -0200)
Pointed out by coverity tests: https://bugs.tizen.org/jira/browse/TC-2097

src/plugins/jpeg/jpeg.c

index 2597e28..12d7624 100644 (file)
@@ -473,7 +473,7 @@ static int
 _exif_data_get(int fd, int len, struct lms_image_info *info)
 {
     const unsigned char exif_hdr[6] = "Exif\0";
-    unsigned char buf[8];
+    unsigned char buf[9];
     unsigned int little_endian, offset, count;
     off_t abs_offset, tiff_base;
 
@@ -498,6 +498,7 @@ _exif_data_get(int fd, int len, struct lms_image_info *info)
         perror("read");
         return -4;
     }
+    buf[sizeof(buf) -1] = '\0';
 
     if (buf[0] == 'I' && buf[1] == 'I') {
         little_endian = 1;