From: Jeongmo Yang Date: Wed, 27 May 2020 06:03:30 +0000 (+0900) Subject: Fix ASAN build error X-Git-Tag: submit/tizen/20200529.081800~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7fc864fae9c4d12b26a2a6bf16d255edfddffdd;p=platform%2Fadaptation%2Fbroadcom%2Flibomxil-vc4.git Fix ASAN build error - Build error is caused by -Werror=stringop-truncation option Change-Id: Ia869d851825d02920b8b835e2a54419b04b77f04 Signed-off-by: Jeongmo Yang --- diff --git a/containers/mkv/matroska_reader.c b/containers/mkv/matroska_reader.c index 8625d0c..df91e8b 100755 --- a/containers/mkv/matroska_reader.c +++ b/containers/mkv/matroska_reader.c @@ -352,7 +352,7 @@ typedef struct VC_CONTAINER_TRACK_MODULE_T int64_t timecode_scale; uint32_t duration; int64_t frame_duration; - char codecid[MKV_CODECID_MAX]; + char codecid[MKV_MAX_STRING_SIZE + 2]; union { /* video specific */ @@ -1320,7 +1320,7 @@ static VC_CONTAINER_STATUS_T mkv_read_subelements_track_entry( VC_CONTAINER_T *p LOG_FORMAT(p_ctx, "%s", stringbuf); if(id == MKV_ELEMENT_ID_TRACK_CODEC_ID) - strncpy(track_module->codecid, stringbuf, MKV_CODECID_MAX-1); + strncpy(track_module->codecid, stringbuf, MKV_MAX_STRING_SIZE + 1); return VC_CONTAINER_SUCCESS; } diff --git a/containers/rtsp/rtsp_reader.c b/containers/rtsp/rtsp_reader.c index 2d96234..5df4d25 100755 --- a/containers/rtsp/rtsp_reader.c +++ b/containers/rtsp/rtsp_reader.c @@ -1052,12 +1052,9 @@ static VC_CONTAINER_STATUS_T rtsp_merge_uris( VC_CONTAINER_T *p_ctx, if (vc_uri_scheme(relative_uri) != NULL) { /* URI is absolute, not relative, so return it as the merged URI */ - size_t len = strlen(relative_uri_str); - - *p_merged_uri_str = (char *)malloc(len + 1); + *p_merged_uri_str = strdup(relative_uri_str); if (!*p_merged_uri_str) goto tidy_up; - strncpy(*p_merged_uri_str, relative_uri_str, len); status = VC_CONTAINER_SUCCESS; goto tidy_up; } @@ -1112,15 +1109,12 @@ static VC_CONTAINER_STATUS_T rtsp_parse_control_attribute( VC_CONTAINER_T *p_ctx if (!*attribute || strcmp(attribute, "*") == 0) { - size_t len = strlen(base_uri_str); - - *p_control_uri_str = (char *)malloc(len + 1); + *p_control_uri_str = strdup(base_uri_str); if (!*p_control_uri_str) { LOG_ERROR(p_ctx, "RTSP: Failed to allocate control URI"); return VC_CONTAINER_ERROR_OUT_OF_MEMORY; } - strncpy(*p_control_uri_str, base_uri_str, len); } else { status = rtsp_merge_uris(p_ctx, base_uri_str, attribute, p_control_uri_str); } @@ -1245,7 +1239,7 @@ static VC_CONTAINER_STATUS_T rtsp_open_file_reader( VC_CONTAINER_T *p_ctx, goto tidy_up; } - strncpy(new_path, rtsp_path, len); + strncpy(new_path, rtsp_path, len + 1); extension = strrchr(new_path, '.'); /* Find extension, to replace it */ if (!extension) extension = new_path + strlen(new_path); /* No extension, so append instead */ diff --git a/host_applications/linux/apps/raspicam/RaspiCamControl.c b/host_applications/linux/apps/raspicam/RaspiCamControl.c index a700010..e46128d 100755 --- a/host_applications/linux/apps/raspicam/RaspiCamControl.c +++ b/host_applications/linux/apps/raspicam/RaspiCamControl.c @@ -1615,7 +1615,7 @@ int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, c strftime(annotate.text, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3, string, &tm ); process_datetime = 0; }else{ - strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3); + strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - 1); } annotate.text[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0'; } @@ -1627,7 +1627,7 @@ int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, c }else{ strftime(tmp, 32, "%X", &tm ); } - strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text) - 1); + strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text)); } if (process_datetime && (settings & ANNOTATE_DATE_TEXT)) @@ -1637,7 +1637,7 @@ int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, c }else{ strftime(tmp, 32, "%x", &tm ); } - strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text) - 1); + strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strlen(annotate.text)); } if (settings & ANNOTATE_SHUTTER_SETTINGS) diff --git a/host_applications/linux/apps/raspicam/RaspiStill.c b/host_applications/linux/apps/raspicam/RaspiStill.c index 0c3cf3f..d791200 100755 --- a/host_applications/linux/apps/raspicam/RaspiStill.c +++ b/host_applications/linux/apps/raspicam/RaspiStill.c @@ -294,7 +294,7 @@ static void set_sensor_defaults(RASPISTILL_STATE *state) state->width = param.cameras[state->cameraNum].max_width; if (state->height == 0) state->height = param.cameras[state->cameraNum].max_height; - strncpy(state->camera_name, param.cameras[state->cameraNum].camera_name, MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN); + strncpy(state->camera_name, param.cameras[state->cameraNum].camera_name, MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN - 1); state->camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN-1] = 0; } else diff --git a/interface/vcos/pthreads/vcos_pthreads.c b/interface/vcos/pthreads/vcos_pthreads.c index 77ce58c..3295f7a 100755 --- a/interface/vcos/pthreads/vcos_pthreads.c +++ b/interface/vcos/pthreads/vcos_pthreads.c @@ -205,7 +205,7 @@ VCOS_STATUS_T vcos_thread_create(VCOS_THREAD_T *thread, thread->arg = arg; thread->legacy = local_attrs->legacy; - strncpy(thread->name, name, sizeof(thread->name)); + strncpy(thread->name, name, sizeof(thread->name) - 1); thread->name[sizeof(thread->name)-1] = '\0'; memset(thread->at_exit, 0, sizeof(thread->at_exit)); diff --git a/interface/vmcs_host/vc_vchi_filesys.c b/interface/vmcs_host/vc_vchi_filesys.c index 26a34b9..29c94db 100755 --- a/interface/vmcs_host/vc_vchi_filesys.c +++ b/interface/vmcs_host/vc_vchi_filesys.c @@ -373,8 +373,8 @@ static int vc_filesys_single_string(uint32_t param, const char *str, uint32_t fn { vc_filesys_client.fileserv_msg.params[0] = param; /* coverity[buffer_size_warning] - the length of str has already been checked */ - strncpy((char*)vc_filesys_client.fileserv_msg.data, str, FILESERV_MAX_DATA); - + strncpy((char*)vc_filesys_client.fileserv_msg.data, str, FILESERV_MAX_DATA - 1); + if (vchi_msg_stub(&vc_filesys_client.fileserv_msg, fn, len+1+16) == FILESERV_RESP_OK) { if(return_param) diff --git a/interface/vmcs_host/vcilcs_out.c b/interface/vmcs_host/vcilcs_out.c index 545ddc7..f5d3c11 100755 --- a/interface/vmcs_host/vcilcs_out.c +++ b/interface/vmcs_host/vcilcs_out.c @@ -689,7 +689,7 @@ static OMX_ERRORTYPE vcil_out_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponen comp = (VC_PRIVATE_COMPONENT_T *) pComp->pComponentPrivate; exe.reference = comp->reference; - strncpy(exe.name, cParameterName, 128); + strncpy(exe.name, cParameterName, 128 - 1); exe.name[127] = 0; if(ilcs_execute_function(st->ilcs, IL_GET_EXTENSION_INDEX, &exe, sizeof(exe), &resp, &rlen) < 0 || rlen != sizeof(resp))