Fix coverity issue 90/154290/2 accepted/tizen/unified/20171011.065944 submit/tizen/20171010.094851
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 10 Oct 2017 04:39:54 +0000 (13:39 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 10 Oct 2017 06:16:53 +0000 (15:16 +0900)
1. Bad bit shift operation : camerasrc.c at line 159
2. Buffer not null terminated : gstcamerasrc.c at line 3136
3. Unused value : gstcamerasrc.c at line 1483

[Version] 0.0.4
[Profile] Common
[Issue Type] Coverity
[Dependency module] N/A

Change-Id: Iafc38c95359da15accfee3300c73b5f19b53e4ee
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
camerasrc/src/camerasrc.c
camerasrc/src/gstcamerasrc.c
packaging/gst-plugins-camera-n4.spec

index 5d65189cff108a797fd13f693bdf3aaee6898601..1cd578b1433feb70fe3326d2373dffff8d28e9b8 100644 (file)
@@ -156,7 +156,10 @@ static int buf_4k_align(unsigned int buf_size)
 {
        unsigned int ret;
 
-       if (buf_size & (PAGE_SIZE - 1)) {
+       if (PAGE_SHIFT < 0) {
+               camsrc_info("invalid page shift %ld, use original size %u", PAGE_SHIFT, buf_size);
+               ret = buf_size;
+       } else if (buf_size & (PAGE_SIZE - 1)) {
                camsrc_info("buf_size(0x%08x) is not 4K aligned", buf_size);
                ret = buf_size + PAGE_SIZE;
                ret &= PAGE_MASK;
index fd1250c915ef84dc58b46aa08c0911ed0820514d..f3b897b3c09571fa8f885bbca11c9b631451fd24 100644 (file)
@@ -1481,6 +1481,11 @@ CHECK_CAPTURE_INTERVAL:
                                        /* emit capture signal */
                                        GST_INFO("                read_capture:gst_camerasrc_emit_capture_signal");
                                        ret = gst_camerasrc_emit_capture_signal(camerasrc, &main_buf, &thumb_buf, &scrnl_buf);
+                                       if (ret == FALSE) {
+                                               gst_buffer_unref(buf->buffer);
+                                               free(buf);
+                                               return GST_FLOW_ERROR;
+                                       }
 
                                        /* free allocated memory
                                        - interleaved data capture mode
@@ -3133,7 +3138,7 @@ static gboolean gst_camerasrc_get_caps_info(GstCameraSrc *camerasrc, GstCaps *ca
                                goto _caps_info_failed;
                        }
 
-                       strncpy(camerasrc->format_name, caps_format_name, sizeof(camerasrc->format_name));
+                       strncpy(camerasrc->format_name, caps_format_name, sizeof(camerasrc->format_name) - 1);
                        caps_fourcc = MAKE_FOURCC_FROM_STRING(camerasrc->format_name);
                        _gst_camerasrc_get_frame_size(caps_fourcc, w, h, size);
                        _gst_camerasrc_get_raw_pixel_info(caps_fourcc, &(camerasrc->pix_format), &(camerasrc->colorspace));
index f241354e587271cdff313d89910fdd05bf943ff8..9e2543086b30a442de540a626e13ecbf5a41ed62 100644 (file)
@@ -1,6 +1,6 @@
 Name:       gst-plugins-camera-n4
 Summary:    GStreamer codec plugins package for N4
-Version:    0.0.3
+Version:    0.0.4
 Release:    0
 Group:      Multimedia/Framework
 License:    LGPL-2.1