snprintf(temp, sizeof(temp), ", playlist.%s AS p_thumbnail_path", col_ptr->name);
else
snprintf(temp, sizeof(temp), ", playlist.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
} else {
snprintf(temp, sizeof(temp), "playlist.%s", col_ptr->name);
- strncpy(table_query, temp, strlen(temp));
+ SAFE_STRLCPY(table_query, temp, sizeof(table_query));
sflag = true;
}
}
snprintf(temp, sizeof(temp), ", media_count IS NOT NULL AS media_count, playlist_map.%s AS pm_id", col_ptr->name);
else
snprintf(temp, sizeof(temp), ", playlist_map.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
if (col_ptr->is_view) {
if (sflag == true) {
snprintf(temp, sizeof(temp), ", tag.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
} else {
snprintf(temp, sizeof(temp), "tag.%s", col_ptr->name);
- strncpy(table_query, temp, strlen(temp));
+ SAFE_STRLCPY(table_query, temp, sizeof(table_query));
sflag = true;
}
}
snprintf(temp, sizeof(temp), ", media_count IS NOT NULL AS media_count, tag_map.%s AS tm_id", col_ptr->name);
else
snprintf(temp, sizeof(temp), ", tag_map.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
if (col_ptr->has_option) {
if (sflag == true) {
snprintf(temp, sizeof(temp), ", %s %s %s", col_ptr->name, col_ptr->type, col_ptr->option);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
} else {
snprintf(temp, sizeof(temp), "%s %s %s", col_ptr->name, col_ptr->type, col_ptr->option);
- strncpy(table_query, temp, strlen(temp));
+ SAFE_STRLCPY(table_query, temp, sizeof(table_query));
sflag = true;
}
} else {
if (sflag == true) {
snprintf(temp, sizeof(temp), ", %s %s", col_ptr->name, col_ptr->type);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
} else {
snprintf(temp, sizeof(temp), "%s %s", col_ptr->name, col_ptr->type);
- strncpy(table_query, temp, strlen(temp));
+ SAFE_STRLCPY(table_query, temp, sizeof(table_query));
sflag = true;
}
}
if (col_ptr->is_unique) {
if (table_sub_len > 0) {
snprintf(temp, sizeof(temp), ", %s", col_ptr->name);
- strncat(table_query_sub, temp, strlen(temp));
+ SAFE_STRLCAT(table_query_sub, temp, sizeof(table_query_sub));
table_sub_len = strlen(table_query_sub);
} else {
snprintf(temp, sizeof(temp), "%s", col_ptr->name);
- strncpy(table_query_sub, temp, strlen(temp));
+ SAFE_STRLCPY(table_query_sub, temp, sizeof(table_query_sub));
table_sub_len = strlen(table_query_sub);
}
}
if (col_ptr->is_index) {
if (index_len > 0) {
snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name);
- strncat(index_query, temp, strlen(temp));
+ SAFE_STRLCAT(index_query, temp, sizeof(index_query));
index_len = strlen(index_query);
} else {
snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_INDEX, col_ptr->index_name, table_name, col_ptr->name);
- strncpy(index_query, temp, strlen(temp));
+ SAFE_STRLCPY(index_query, temp, sizeof(index_query));
index_len = strlen(index_query);
}
}
if (STRING_VALID(tb->trigger_name)) {
if (strncmp(table_name, MEDIA_SVC_DB_TABLE_ALBUM, strlen(MEDIA_SVC_DB_TABLE_ALBUM)) == 0) {
snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_TRIGGER_WITH_COUNT, tb->trigger_name, tb->event_table, tb->action_table, tb->event_table, col_ptr->name, col_ptr->name, col_ptr->name, col_ptr->name);
- strncpy(trigger_query, temp, strlen(temp));
+ SAFE_STRLCPY(trigger_query, temp, sizeof(trigger_query));
trigger_len = strlen(trigger_query);
} else {
snprintf(temp, sizeof(temp), MEDIA_SVC_DB_QUERY_TRIGGER, tb->trigger_name, tb->event_table, tb->action_table, col_ptr->name, col_ptr->name);
- strncpy(trigger_query, temp, strlen(temp));
+ SAFE_STRLCPY(trigger_query, temp, sizeof(trigger_query));
trigger_len = strlen(trigger_query);
}
} else {
snprintf(temp, sizeof(temp), ", playlist.%s AS p_thumbnail_path", col_ptr->name);
else
snprintf(temp, sizeof(temp), ", playlist.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
} else {
snprintf(temp, sizeof(temp), "playlist.%s", col_ptr->name);
- strncpy(table_query, temp, strlen(temp));
+ SAFE_STRLCPY(table_query, temp, sizeof(table_query));
sflag = true;
}
}
snprintf(temp, sizeof(temp), ", media_count IS NOT NULL AS media_count, playlist_map.%s AS pm_id", col_ptr->name);
else
snprintf(temp, sizeof(temp), ", playlist_map.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
if (col_ptr->is_view) {
if (sflag == true) {
snprintf(temp, sizeof(temp), ", tag.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
} else {
snprintf(temp, sizeof(temp), "tag.%s", col_ptr->name);
- strncpy(table_query, temp, strlen(temp));
+ SAFE_STRLCPY(table_query, temp, sizeof(table_query));
sflag = true;
}
}
snprintf(temp, sizeof(temp), ", media_count IS NOT NULL AS media_count, tag_map.%s AS tm_id", col_ptr->name);
else
snprintf(temp, sizeof(temp), ", tag_map.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
- strncat(table_query, temp, strlen(temp));
+ SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
}
if (query_len >= SQLITE3_QUERY_MAX_LEN) {
media_svc_error("NEED TO CHECK FILE : A single query size exceeds 8k [%d]", query_len);
} else {
- strncpy(query_bundle, sql, query_len);
+ SAFE_STRLCPY(query_bundle, sql, sizeof(query_bundle));
total_len = query_len;
}
} else {
- strncat(query_bundle, sql, query_len);
+ SAFE_STRLCAT(query_bundle, sql, sizeof(query_bundle));
total_len += query_len;
}
char append_query[128] = {0, };
memset(append_query, 0x00, sizeof(append_query));
snprintf(append_query, sizeof(append_query), " UNION SELECT * from '%s'", storage_id);
- strncat(view_query, append_query, strlen(append_query));
+ SAFE_STRLCAT(view_query, append_query, sizeof(view_query));
} else {
media_svc_error("media table not exist for storage [%s]", storage_id);
}
status = U_ZERO_ERROR;
tmp_result = calloc(1, sizeof(UChar) * (size + 1));
- u_strFromUTF8(tmp_result, size + 1, NULL, src, -1, &status);
- if (U_FAILURE(status)) {
- media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status));
- ret = MS_MEDIA_ERR_INTERNAL;
- goto DATA_FREE;
+ if (tmp_result != NULL) {
+ u_strFromUTF8(tmp_result, size + 1, NULL, src, -1, &status);
+ if (U_FAILURE(status)) {
+ media_svc_error("u_strFromUTF8 Failed(%s)", u_errorName(status));
+ ret = MS_MEDIA_ERR_INTERNAL;
+ goto DATA_FREE;
+ }
}
-
result_len = 0;
temp_dest = calloc(1, sizeof(char) * temp_dest_size);
- for (i = 0; i < size; i++) {
- char *tmp = NULL;
- int tmp_size = 0;
- UChar *bopomofo = calloc(1, sizeof(UChar) * 4);
- if (bopomofo == NULL) {
- media_svc_error("u_strToUTF8 to allocate memory Failed");
- ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- __media_svc_get_bopomofo(tmp_result[i], bopomofo, &len);
+ if (temp_dest != NULL) {
+ for (i = 0; i < size; i++) {
+ char *tmp = NULL;
+ int tmp_size = 0;
+ UChar *bopomofo = calloc(1, sizeof(UChar) * 4);
+ if (bopomofo == NULL) {
+ media_svc_error("u_strToUTF8 to allocate memory Failed");
+ ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ __media_svc_get_bopomofo(tmp_result[i], bopomofo, &len);
- u_strToUTF8(NULL, 0, &tmp_size, bopomofo, -1, &status);
- if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) {
- media_svc_error("u_strToUTF8 to get the dest length Failed(%s)", u_errorName(status));
- ret = MS_MEDIA_ERR_INTERNAL;
- free(bopomofo);
- goto DATA_FREE;
- }
+ u_strToUTF8(NULL, 0, &tmp_size, bopomofo, -1, &status);
+ if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) {
+ media_svc_error("u_strToUTF8 to get the dest length Failed(%s)", u_errorName(status));
+ ret = MS_MEDIA_ERR_INTERNAL;
+ free(bopomofo);
+ goto DATA_FREE;
+ }
- status = U_ZERO_ERROR;
- tmp = calloc(1, sizeof(char) * (tmp_size + 1));
- if (tmp == NULL) {
- media_svc_error("u_strToUTF8 to allocate memory Failed");
- ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
- free(bopomofo);
- goto DATA_FREE;
- }
+ status = U_ZERO_ERROR;
+ tmp = calloc(1, sizeof(char) * (tmp_size + 1));
+ if (tmp == NULL) {
+ media_svc_error("u_strToUTF8 to allocate memory Failed");
+ ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
+ free(bopomofo);
+ goto DATA_FREE;
+ }
- u_strToUTF8(tmp, tmp_size + 1, &tmp_size, bopomofo, -1, &status);
- result_len += SAFE_SNPRINTF(&temp_dest, &temp_dest_size, result_len, tmp);
+ u_strToUTF8(tmp, tmp_size + 1, &tmp_size, bopomofo, -1, &status);
+ result_len += SAFE_SNPRINTF(&temp_dest, &temp_dest_size, result_len, tmp);
- free(tmp);
- free(bopomofo);
+ free(tmp);
+ free(bopomofo);
+ }
}
*dest = temp_dest;
/* Get the contents of the tag in human-readable form */
char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = {0, };
+ memset(gps_buf, 0, sizeof(gps_buf));
exif_entry_get_value(entry, gps_buf, sizeof(gps_buf));
- gps_buf[strlen(gps_buf)] = '\0';
int ret = MS_MEDIA_ERR_NONE;
double tmp_arr[3] = { 0.0, 0.0, 0.0 };
}
exif_entry_get_value(entry, buf, MEDIA_SVC_METADATA_LEN_MAX);
- buf[strlen(buf)] = '\0';
}
}
char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
char description_buf[MEDIA_SVC_METADATA_DESCRIPTION_MAX + 1] = { '\0' };
- char exposure_time_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
- char model_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
memset(buf, 0x00, sizeof(buf));
memset(description_buf, 0x00, sizeof(description_buf));
- memset(exposure_time_buf, 0x00, sizeof(exposure_time_buf));
- memset(model_buf, 0x00, sizeof(model_buf));
if (content_info == NULL || content_info->media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE) {
media_svc_error("content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE");
content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
}
- memset(buf, 0x00, sizeof(buf));
+ memset(description_buf, 0x00, sizeof(description_buf));
if (__media_svc_get_exif_info(ed, description_buf, NULL, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
if (strlen(description_buf) == 0) {
media_svc_debug("Timeline : %ld", content_info->timeline);
}
+ memset(buf, 0x00, sizeof(buf));
+
/* Get exposure_time value from exif. */
- if (__media_svc_get_exif_info(ed, exposure_time_buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
- if (strlen(exposure_time_buf) == 0) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) == 0) {
/* media_svc_debug("exposure_time_buf is NULL"); */
} else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.exposure_time, exposure_time_buf);
+ ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.exposure_time, buf);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}
content_info->media_meta.iso = 0;
}
+ memset(buf, 0x00, sizeof(buf));
+
/* Get model value from exif. */
- if (__media_svc_get_exif_info(ed, model_buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
- if (strlen(model_buf) == 0) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) == 0) {
/* media_svc_debug("model_buf is NULL"); */
} else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.model, model_buf);
+ ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.model, buf);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("strcpy error");
}