*
* result = datacontrol_map_create(&provider);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Creating data control provider is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Creating data control provider is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_map_set_provider_id(provider, provider_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Setting providerID is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Setting providerID is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_map_set_data_id(provider, data_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Setting dataID is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Setting dataID is failed with error: %d", result);
* return result;
* }
*
*
* result = datacontrol_map_destroy(provider);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Destorying data control provider is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Destorying data control provider is failed with error: %d", result);
* }
*
* return result;
* char **result_value_list, int result_value_count, bool provider_result, const char *error)
* {
* if (provider_result) {
- * LOGI("The get operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The get operation is successful");
* }
* else {
- * LOGI("The get operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The get operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* map_callback.get = map_get_response_cb;
* result = datacontrol_map_register_response_cb(provider, &map_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_map_get(provider, key, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Getting the value list of the key(%s) is failed with error: %d", key, result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Getting the value list of the key(%s) is failed with error: %d", key, result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* return result;
* void map_set_response_cb(int request_id, datacontrol_h provider, bool provider_result, const char *error)
* {
* if (provider_result) {
- * LOGI("The set operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The set operation is successful");
* }
* else {
- * LOGI("The set operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The set operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* map_callback.set = map_set_response_cb;
* result = datacontrol_map_register_response_cb(provider, &map_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_map_set(provider, key, old_value, new_value, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Replacing old_value(%s) with new_value(%s) is failed with error: %d", old_value, new_value, result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Replacing old_value(%s) with new_value(%s) is failed with error: %d", old_value, new_value, result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* return result;
*
* void map_add_response_cb(int request_id, datacontrol_h provider, bool provider_result, const char *error) {
* if (provider_result) {
- * LOGI("The add operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The add operation is successful");
* }
* else {
- * LOGI("The add operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The add operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* map_callback.add = map_add_response_cb;
* result = datacontrol_map_register_response_cb(provider, &map_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_map_add(provider, key, value, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Adding %s-%s pair is failed with error: %d", key, value, result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Adding %s-%s pair is failed with error: %d", key, value, result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* return result;
*
* void map_remove_response_cb(int request_id, datacontrol_h provider, bool provider_result, const char *error) {
* if (provider_result) {
- * LOGI("The remove operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The remove operation is successful");
* }
* else {
- * LOGI("The remove operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The remove operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* map_callback.remove = map_remove_response_cb;
* result = datacontrol_map_register_response_cb(provider, &map_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_map_remove(provider, key, value, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Removing %s-%s pair is failed with error: %d", key, value, result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Removing %s-%s pair is failed with error: %d", key, value, result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* return result;
*
* result = datacontrol_sql_create(&provider);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Creating data control provider is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Creating data control provider is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_sql_set_provider_id(provider, provider_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Setting providerID is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Setting providerID is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_sql_set_data_id(provider, data_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Setting dataID is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Setting dataID is failed with error: %d", result);
* return result;
* }
*
*
* result = datacontrol_sql_destroy(provider);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Destorying data control provider is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Destorying data control provider is failed with error: %d", result);
* }
*
* return result;
*
* void sql_delete_response_cb(int request_id, datacontrol_h provider, bool provider_result, const char *error) {
* if (provider_result) {
- * LOGI("The delete operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The delete operation is successful");
* }
* else {
- * LOGI("The delete operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The delete operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* sql_callback.delete = sql_delete_response_cb;
* result = datacontrol_sql_register_response_cb(provider, &sql_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_sql_delete(provider, where, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Deleting is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Deleting is failed with error: %d", result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* return result;
*
* void sql_insert_response_cb(int request_id, datacontrol_h provider, long long inserted_row_id, bool provider_result, const char *error) {
* if (provider_result) {
- * LOGI("The insert operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The insert operation is successful");
* }
* else {
- * LOGI("The insert operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The insert operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* sql_callback.insert = sql_insert_response_cb;
* result = datacontrol_sql_register_response_cb(provider, &sql_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
*
* result = datacontrol_sql_insert(provider, b, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Inserting is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Inserting is failed with error: %d", result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* bundle_free(b);
*
* void sql_select_response_cb(int request_id, datacontrol_h provider, resultset_cursor *enumerator, bool provider_result, const char *error) {
* if (provider_result) {
- * LOGI("The select operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The select operation is successful");
* }
* else {
- * LOGI("The select operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The select operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* sql_callback.select = sql_select_response_cb;
* result = datacontrol_sql_register_response_cb(provider, &sql_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
* result = datacontrol_sql_select(provider, column_list, 2, where, order, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Selecting is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Selecting is failed with error: %d", result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* return result;
*
* void sql_update_response_cb(int request_id, datacontrol_h provider, bool provider_result, const char *error) {
* if (provider_result) {
- * LOGI("The update operation is successful");
+ * dlog_print(DLOG_INFO, LOG_TAG, "The update operation is successful");
* }
* else {
- * LOGI("The update operation for the request %d is failed. error message: %s", request_id, error);
+ * dlog_print(DLOG_INFO, LOG_TAG, "The update operation for the request %d is failed. error message: %s", request_id, error);
* }
* }
*
* sql_callback.update = sql_update_response_cb;
* result = datacontrol_sql_register_response_cb(provider, &sql_callback);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Registering the callback function is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Registering the callback function is failed with error: %d", result);
* return result;
* }
*
*
* result = datacontrol_sql_update(provider, b, where, &req_id);
* if (result != DATACONTROL_ERROR_NONE) {
- * LOGE("Updating is failed with error: %d", result);
+ * dlog_print(DLOG_ERROR, LOG_TAG, "Updating is failed with error: %d", result);
* }
* else {
- * LOGI("req_id is %d", req_id);
+ * dlog_print(DLOG_INFO, LOG_TAG, "req_id is %d", req_id);
* }
*
* bundle_free(b);
return 0;
}
+
int
_datacontrol_create_request_id(void)
{
}
value_list[i] = (char *) calloc(length + 1, sizeof(char));
- if (value_list[i] == NULL) {
- SECURE_LOGE("out of memory");
- goto ERROR;
- }
size = read(fd, value_list[i], length);
if (size <= 0)
pid = -1;
int count = 0;
const int TRY_COUNT = 4;
- const int TRY_SLEEP_TIME = 65000;
+ const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
+
do
{
pid = appsvc_run_service(arg_list, request_id, app_svc_res_cb_map, data);
count++;
- usleep(TRY_SLEEP_TIME);
+ nanosleep(&TRY_SLEEP_TIME, 0);
}
while (count < TRY_COUNT);
char* access = NULL;
char *provider_appid = NULL;
- if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || key == NULL)
+ if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || key == NULL || page_number <= 0 || count_per_page <= 0)
{
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
#include <appsvc/appsvc.h>
#include <aul/aul.h>
#include <bundle.h>
+#include <bundle_internal.h>
#include <pkgmgr-info.h>
#include <security-server.h>
#define PACKET_INDEX_MAP_PAGE_NO 2
#define PACKET_INDEX_MAP_COUNT_PER_PAGE 3
+#define ERR_LEN 128
+
static const int MAX_ARGUMENT_SIZE = 16384; // 16KB
static GHashTable *request_table = NULL;
{
const char *caller_appid = NULL;
char *caller_pkgid = NULL;
+ char *pkgid_dup = NULL;
pkgmgrinfo_appinfo_h app_info_handle = NULL;
+ if (b == NULL) {
+ LOGE("Bundle passed is NULL");
+ return NULL;
+ }
+
caller_appid = bundle_get_val(b, AUL_K_CALLER_APPID);
- pkgmgrinfo_appinfo_get_appinfo(caller_appid, &app_info_handle);
- pkgmgrinfo_appinfo_get_pkgname(app_info_handle, &caller_pkgid);
- SECURE_LOGI("client pkg id : %s", caller_pkgid);
+ if (caller_appid == NULL) {
+ LOGE("caller_appid is NULL");
+ return NULL;
+ }
- return caller_pkgid ? strdup(caller_pkgid) : NULL;
+ if (pkgmgrinfo_appinfo_get_appinfo(caller_appid, &app_info_handle) != PMINFO_R_OK) {
+ SECURE_LOGE("unable to get appinfo of provider_appid: %s", caller_appid);
+ } else {
+ if (pkgmgrinfo_appinfo_get_pkgname(app_info_handle, &caller_pkgid) != PMINFO_R_OK) {
+ SECURE_LOGE("unable to get pkgname of provider_appid: %s", caller_appid);
+ } else {
+ SECURE_LOGI("provider pkg id : %s", caller_pkgid);
+ pkgid_dup = strdup(caller_pkgid);
+ if (pkgid_dup == NULL)
+ SECURE_LOGE("OOM error");
+ }
+ pkgmgrinfo_appinfo_destroy_appinfo(app_info_handle);
+ }
+ return pkgid_dup;
}
static bundle*
char *value = NULL;
int fd = 0;
int ret = 0;
+ char err_buf[ERR_LEN] = { 0, };
SECURE_LOGI("The request file of INSERT/UPDATE: %s", path);
ret = security_server_shared_file_reopen(path, &fd);
size = read(fd, &len, sizeof(int));
if ((unsigned int)size < sizeof(int) || len < 0 || len > MAX_ARGUMENT_SIZE)
{
- SECURE_LOGE("key length:%d, read():%s, returned:%d", len, strerror(errno), size);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("key length:%d, read():%s, returned:%d", len, err_buf, size);
break;
}
key = calloc(len + 1, sizeof(char));
if (key == NULL) {
- SECURE_LOGE("out of memory");
+ LOGE("OOM error");
break;
}
-
- size = read(fd, key, len); // key
+ size = read(fd, key, len); // key
+ key[len] = '\0';
if (size < 0)
{
- SECURE_LOGE("key length:%d, read():%s, returned:%d", len, strerror(errno), size);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("key length:%d, read():%s, returned:%d", len, err_buf, size);
free(key);
+ key = NULL;
break;
}
size = read(fd, &len, sizeof(int));
if ((unsigned int)size < sizeof(int) || len < 0 || len > MAX_ARGUMENT_SIZE)
{
- SECURE_LOGE("value length:%d, read():%s, returned:%d", len, strerror(errno), size);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("value length:%d, read():%s, returned:%d", len, err_buf, size);
free(key);
+ key = NULL;
break;
}
value = calloc(len + 1, sizeof(char));
if (value == NULL) {
- SECURE_LOGE("out of memory");
+ LOGE("OOM error");
free(key);
+ key = NULL;
break;
}
size = read(fd, value, len); // value
if (size < 0)
{
- SECURE_LOGE("value length:%d, read():%s, returned:%d", len, strerror(errno), size);
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("value length:%d, read():%s, returned:%d", len, err_buf, size);
free(key);
+ key = NULL;
free(value);
+ value = NULL;
break;
}
- LOGI("key: %s, value: %s", key, value);
+ SECURE_LOGI("key: %s, value: %s", key, value);
bundle_add_str(b, key, value);
- free(key);
- free(value);
+ if (key != NULL) {
+ free(key);
+ key = NULL;
+ }
+ if (value != NULL) {
+ free(value);
+ value = NULL;
+ }
}
fsync(fd);
}
client_pkgid = __get_client_pkgid(b);
+ if (client_pkgid == NULL) {
+ LOGE("could not get client package id");
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
+
ret = security_server_shared_file_open(path, client_pkgid, &fd);
if (ret == SECURITY_SERVER_API_ERROR_FILE_EXIST) {
SECURE_LOGE("The file(%s) already exist, delete and retry to open", path);
if (column_name == NULL) {
LOGE("sqlite3_column_name is failed. errno = %d", errno);
} else {
- column_name = strcat(column_name, "\n");
+ column_name = strncat(column_name, "\n", 1);
if (write(fd, column_name, strlen(column_name)) == -1)
{
LOGE("Writing a column_name to a file descriptor is failed. errno = %d", errno);
LOGE("Writing a row_count to a file descriptor is failed. errno = %d", errno);
}
close(fd);
-
-
return DATACONTROL_ERROR_NONE;
}
}
client_pkgid = __get_client_pkgid(b);
+ if (client_pkgid == NULL) {
+ LOGE("could not get client package id");
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
+
ret = security_server_shared_file_open(path, client_pkgid, &fd);
if (ret == SECURITY_SERVER_API_ERROR_FILE_EXIST) {
SECURE_LOGE("The file(%s) already exist, delete and retry to open", path);
for (i = 0; i < add_value_count; ++i)
{
int length = strlen(value_list[current_offset + i]);
+ if (length >= INT_MAX) {
+ LOGE("Integer overflow. value_list[%d]", current_offset + i);
+ fsync(fd);
+ close(fd);
+ return DATACONTROL_ERROR_MAX_EXCEEDED;
+ }
if (write(fd, &length, sizeof(int)) == -1)
{
LOGE("Writing a length to a file descriptor is failed. errno = %d", errno);
}
const char *caller_req_id = bundle_get_val(b, OSP_K_REQUEST_ID);
-
+ if (caller_req_id == NULL) {
+ LOGE("caller req_id is NULL.");
+ return NULL;
+ }
char *result_path = calloc(RESULT_PATH_MAX, sizeof(char));
if (!result_path)
if (ret < 0)
{
memset(path, 0, RESULT_PATH_MAX);
- strcpy(path, "NoResultSet");
+ strncpy(path, "NoResultSet", RESULT_PATH_MAX);
LOGI("Empty ResultSet");
}
list[PACKET_INDEX_SELECT_RESULT_FILE] = path;
list[PACKET_INDEX_REQUEST_RESULT] = "1"; // request result
list[PACKET_INDEX_ERROR_MSG] = DATACONTROL_EMPTY;
+ list[PACKET_INDEX_VALUE_COUNT] = "0"; // value count
+ list[PACKET_INDEX_GET_RESULT_FILE] = DATACONTROL_EMPTY;
char *path = __get_result_file_path(b);
if (path != NULL)
{
char **value_list = (char **)data;
- __set_get_value_result(b, path, value_list);
- list[PACKET_INDEX_VALUE_COUNT] = bundle_get_val(b, RESULT_VALUE_COUNT); // value count
- list[PACKET_INDEX_GET_RESULT_FILE] = path;
- }
- else
- {
- list[PACKET_INDEX_VALUE_COUNT] = 0; // value count
- list[PACKET_INDEX_GET_RESULT_FILE] = DATACONTROL_EMPTY;
+ if (__set_get_value_result(b, path, value_list) == DATACONTROL_ERROR_NONE)
+ {
+ list[PACKET_INDEX_VALUE_COUNT] = bundle_get_val(b, RESULT_VALUE_COUNT); // value count
+ list[PACKET_INDEX_GET_RESULT_FILE] = path;
+ }
}
bundle_add_str_array(res, OSP_K_ARG, list, 4);
{
free(path);
}
-
break;
}
case DATACONTROL_TYPE_UNDEFINED: // DATACONTROL_TYPE_MAP_SET || ADD || REMOVE
}
int len = 0;
+ int ret = DATACONTROL_ERROR_NONE;
const char **arg_list = bundle_get_str_array(b, OSP_K_ARG, &len);
- datacontrol_h provider = malloc(sizeof(struct datacontrol_s));
+ datacontrol_h provider = calloc(1, sizeof(struct datacontrol_s));
if (provider == NULL) {
LOGE("Fail to alloc provider");
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
// Set the provider ID
- provider->provider_id = (char*)bundle_get_val(b, OSP_K_DATACONTROL_PROVIDER);
+ provider->provider_id = strdup((char*)bundle_get_val(b, OSP_K_DATACONTROL_PROVIDER));
// Set the data ID
- provider->data_id = (char*)arg_list[PACKET_INDEX_DATAID];
+ provider->data_id = strdup((char*)arg_list[PACKET_INDEX_DATAID]);
// Set the request ID
int provider_req_id = __provider_new_request_id();
// Add the data to the table
int *key = malloc(sizeof(int));
if (key == NULL) {
- free(provider);
- LOGE("Fail to alloc key");
- return DATACONTROL_ERROR_OUT_OF_MEMORY;
+ LOGE("OOM error");
+ ret = DATACONTROL_ERROR_OUT_OF_MEMORY;
+ goto EXCEPTION;
}
*key = provider_req_id;
int current = 0;
int column_count = atoi(arg_list[i++]); // Column count
- LOGI("SELECT column count: %d", column_count);
+ SECURE_LOGI("SELECT column count: %d", column_count);
const char** column_list = (const char**)malloc(column_count * (sizeof(char *)));
if (column_list == NULL) {
while (current < column_count)
{
column_list[current++] = arg_list[i++]; // Column data
-
- LOGI("Column %d: %s", current, column_list[current-1]);
+ SECURE_LOGI("Column %d: %s", current, column_list[current-1]);
}
const char *where = arg_list[i++]; // where
const char *order = arg_list[i++]; // order
- LOGI("where: %s, order: %s", where, order);
+ SECURE_LOGI("where: %s, order: %s", where, order);
if (strncmp(where, DATACONTROL_EMPTY, strlen(DATACONTROL_EMPTY)) == 0)
{
bundle_add_str(value, MAX_COUNT_PER_PAGE, per_page);
provider_sql_cb->select(provider_req_id, provider, column_list, column_count, where, order, provider_sql_user_data);
-
free(column_list);
break;
else
{
const char *where = arg_list[PACKET_INDEX_UPDATEWHERE];
- LOGI("UPDATE from where: %s", where);
+ SECURE_LOGI("UPDATE from where: %s", where);
if (strncmp(where, DATACONTROL_EMPTY, strlen(DATACONTROL_EMPTY)) == 0)
{
{
const char *where = arg_list[PACKET_INDEX_DELETEWHERE];
- LOGI("DELETE from where: %s", where);
+ SECURE_LOGI("DELETE from where: %s", where);
if (strncmp(where, DATACONTROL_EMPTY, strlen(DATACONTROL_EMPTY)) == 0)
{
where = NULL;
bundle_add_str(value, RESULT_PAGE_NUMBER, page_number);
bundle_add_str(value, MAX_COUNT_PER_PAGE, count_per_page);
- LOGI("Gets the value list related with the key(%s) from Map datacontrol. ", map_key);
+ SECURE_LOGI("Gets the value list related with the key(%s) from Map datacontrol. ", map_key);
provider_map_cb->get(provider_req_id, provider, map_key, provider_map_user_data);
break;
const char *old_value = arg_list[PACKET_INDEX_MAP_VALUE_1ST];
const char *new_value = arg_list[PACKET_INDEX_MAP_VALUE_2ND];
- LOGI("Sets the old value(%s) of the key(%s) to the new value(%s) in Map datacontrol.", old_value, map_key, new_value);
+ SECURE_LOGI("Sets the old value(%s) of the key(%s) to the new value(%s) in Map datacontrol.", old_value, map_key, new_value);
provider_map_cb->set(provider_req_id, provider, map_key, old_value, new_value, provider_map_user_data);
break;
const char *map_key = arg_list[PACKET_INDEX_MAP_KEY];
const char *map_value = arg_list[PACKET_INDEX_MAP_VALUE_1ST];
- LOGI("Adds the %s-%s in Map datacontrol.", map_key, map_value);
+ SECURE_LOGI("Adds the %s-%s in Map datacontrol.", map_key, map_value);
provider_map_cb->add(provider_req_id, provider, map_key, map_value, provider_map_user_data);
break;
const char *map_key = arg_list[PACKET_INDEX_MAP_KEY];
const char *map_value = arg_list[PACKET_INDEX_MAP_VALUE_1ST];
- LOGI("Removes the %s-%s in Map datacontrol.", map_key, map_value);
+ SECURE_LOGI("Removes the %s-%s in Map datacontrol.", map_key, map_value);
provider_map_cb->remove(provider_req_id, provider, map_key, map_value, provider_map_user_data);
break;
break;
}
- free(provider);
+EXCEPTION:
+ if(provider && provider->provider_id)
+ free(provider->provider_id);
- return DATACONTROL_ERROR_NONE;
+ if(provider && provider->data_id)
+ free(provider->data_id);
+
+ if(provider)
+ free(provider);
+
+ return ret;
}
int
#include <string.h>
#include <unistd.h>
#include <security-server.h>
+#include <limits.h>
#include "data-control-sql-cursor.h"
#endif
#define MAX_ROW_COUNT 1024
+#define MAX_COLUMN_NAME_LEN 4096
+#define ERR_LEN 128
static int *row_offset_list = NULL;
int datacontrol_sql_get_column_name(resultset_cursor *cursor, int column_index, char *name)
{
- char col_name[4096] = {0, };
+ char col_name[MAX_COLUMN_NAME_LEN] = {0, };
int i = 0;
int ret = 0;
FILE *fp = NULL;
int resultset_fd = 0;
+ int col_name_len = 0;
+ char err_buf[ERR_LEN] = { 0, };
resultset_fd = dup(cursor->resultset_fd);
if (resultset_fd < 0)
{
- LOGE("unable to dup resultset_fd: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to dup resultset_fd: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
fp = fdopen(resultset_fd, "r");
if (fp == NULL)
{
- LOGE("unable to open resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to open resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = fseek(fp, cursor->resultset_col_name_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
fclose(fp);
return DATACONTROL_ERROR_IO_ERROR;
}
for (i = 0; i < column_index + 1; i++)
{
- if (!(fgets(col_name, 4096, fp)))
+ if (!(fgets(col_name, MAX_COLUMN_NAME_LEN, fp)))
{
- LOGE("unable to read a line in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read a line in the resultset file: %s", err_buf);
fclose(fp);
return DATACONTROL_ERROR_IO_ERROR;
}
}
- memset(name, 0, strlen(col_name)); // To avoid copying newline
- memcpy(name, col_name, strlen(col_name) - 1);
+ col_name_len = strlen(col_name);
+
+ if (col_name_len > 0) {
+ memset(name, 0, strlen(col_name)); // To avoid copying newline
+ memcpy(name, col_name, strlen(col_name) - 1);
+ } else {
+ LOGE("col_name length is less than 1");
+ fclose(fp);
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
LOGI("The column name is %s", name);
int i = 0;
int ret = 0;
+ char err_buf[ERR_LEN] = { 0, };
int fd = cursor->resultset_fd;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = lseek(fd, size, SEEK_CUR);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
int i = 0;
int size = 0;
int ret = 0;
-
+ char err_buf[ERR_LEN] = { 0, };
int fd = cursor->resultset_fd;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = lseek(fd, size, SEEK_CUR);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
int size = 0;
int i = 0;
int ret = 0;
-
+ char err_buf[ERR_LEN] = { 0, };
int fd = cursor->resultset_fd;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = lseek(fd, size, SEEK_CUR);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
return DATACONTROL_ERROR_MAX_EXCEEDED; //overflow
}
- if (size > 0)
+ if (size > 0 && size < INT_MAX)
{
- char *data = (char*)malloc((size + 1) * (sizeof(char)));
- if (data == NULL) {
- LOGE("out of memory");
- return DATACONTROL_ERROR_OUT_OF_MEMORY;
+ if (memset(buffer, 0, size + 1) == NULL) {
+ return DATACONTROL_ERROR_IO_ERROR;
}
- memset(data, 0, size + 1);
-
- ret = read(fd, data, size);
- if (ret < size)
- {
- LOGE("unable to read in the resultset file: %s", strerror(errno));
- free(data);
+ ret = read(fd, buffer, size);
+ if (ret < size) {
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
- memcpy(buffer, data, size + 1);
- free(data);
}
return DATACONTROL_ERROR_NONE;
}
int size = 0;
int i = 0;
int ret = 0;
-
+ char err_buf[ERR_LEN] = { 0, };
int fd = cursor->resultset_fd;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = lseek(fd, size, SEEK_CUR);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, data, size);
if (ret < size)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
int size = 0;
int i = 0;
int ret = 0;
-
+ char err_buf[ERR_LEN] = { 0, };
int fd = cursor->resultset_fd;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = lseek(fd, size, SEEK_CUR);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, data, size);
if (ret < size)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
int size = 0;
int i = 0;
int ret = 0;
-
+ char err_buf[ERR_LEN] = { 0, };
int fd = cursor->resultset_fd;
ret = lseek(fd, cursor->resultset_current_offset, SEEK_SET);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = lseek(fd, size, SEEK_CUR);
if (ret < 0)
{
- LOGE("unable to seek in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to seek in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
}
ret = read(fd, &type, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
ret = read(fd, &size, sizeof(int));
if (ret == 0)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
return DATACONTROL_ERROR_IO_ERROR;
}
- if (size > 0)
+ if (size > 0 && size < INT_MAX)
{
char *data = (char*)malloc((size + 1) * (sizeof(char)));
if(!data)
ret = read(fd, data, size);
if (ret < size)
{
- LOGE("unable to read in the resultset file: %s", strerror(errno));
+ strerror_r(errno, err_buf, sizeof(err_buf));
+ LOGE("unable to read in the resultset file: %s", err_buf);
free(data);
return DATACONTROL_ERROR_IO_ERROR;
}
#include <unistd.h>
#include <glib.h>
#include <pthread.h>
+#include <limits.h>
#include <appsvc/appsvc.h>
#include <aul/aul.h>
pid = -1;
int count = 0;
const int TRY_COUNT = 4;
- const int TRY_SLEEP_TIME = 65000;
+ const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
+
do
{
pid = appsvc_run_service(arg_list, request_id, app_svc_res_cb_sql, data);
count++;
- usleep(TRY_SLEEP_TIME);
+ nanosleep(&TRY_SLEEP_TIME, 0);
}
while (count < TRY_COUNT);
__get_provider_pkgid(char* provider_id)
{
char* access = NULL;
+ char *pkgid_dup = NULL;
char *provider_appid = NULL;
char *provider_pkgid = NULL;
pkgmgrinfo_appinfo_h app_info_handle = NULL;
LOGE("unable to get sql data control information: %d", ret);
return NULL;
}
+ if (provider_appid == NULL) {
+ LOGE("provider_appid is NULL");
+ if (access)
+ free(access);
+ return NULL;
+ }
- pkgmgrinfo_appinfo_get_appinfo(provider_appid, &app_info_handle);
- pkgmgrinfo_appinfo_get_pkgname(app_info_handle, &provider_pkgid);
- SECURE_LOGI("provider pkg id : %s", provider_pkgid);
+ if (pkgmgrinfo_appinfo_get_appinfo(provider_appid, &app_info_handle) != PMINFO_R_OK) {
+ SECURE_LOGE("unable to get appinfo of provider_appid: %s", provider_appid);
+ } else {
+ if (pkgmgrinfo_appinfo_get_pkgname(app_info_handle, &provider_pkgid) != PMINFO_R_OK) {
+ SECURE_LOGE("unable to get pkgname of provider_appid: %s", provider_appid);
+ } else {
+ SECURE_LOGI("provider pkg id : %s", provider_pkgid);
+ pkgid_dup = strdup(provider_pkgid);
+ if (pkgid_dup == NULL)
+ SECURE_LOGE("OOM error");
+ }
+ pkgmgrinfo_appinfo_destroy_appinfo(app_info_handle);
+ }
if (access)
- {
free(access);
- }
- if (provider_appid)
- {
- free(provider_appid);
- }
- return provider_pkgid ? strdup(provider_pkgid) : NULL;
+ free(provider_appid);
+ return pkgid_dup;
}
int
int fd = 0;
char *provider_pkgid = __get_provider_pkgid(provider->provider_id);
+ if (provider_pkgid == NULL) {
+ LOGE("Unable to get the provider pkgid");
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
ret = security_server_shared_file_open(insert_map_file, provider_pkgid, &fd);
if (ret == SECURITY_SERVER_API_ERROR_FILE_EXIST) {
free(provider_pkgid);
int count = bundle_get_count((bundle*)insert_data);
- LOGI("Insert column counts: %d", count);
+ SECURE_LOGI("Insert column counts: %d", count);
bundle_foreach((bundle*)insert_data, bundle_foreach_cb, &fd);
char* access = NULL;
char *provider_appid = NULL;
- if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL)
+ if (provider == NULL || provider->provider_id == NULL || provider->data_id == NULL || page_number <= 0 || count_per_page <= 0)
{
LOGE("Invalid parameter");
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
+ SECURE_LOGI("SQL data control, select to provider_id: %s, data_id: %s, col_count: %d, where: %s, order: %s, page_number: %d, per_page: %d", provider->provider_id, provider->data_id, column_count, where, order, page_number, count_per_page);
+
+ ret = pkgmgrinfo_appinfo_get_datacontrol_info(provider->provider_id, "Sql", &provider_appid, &access);
+ if (ret != PMINFO_R_OK)
+ {
+ LOGE("unable to get sql data control information: %d", ret);
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
+ if (provider_appid)
+ free(provider_appid);
+
+ if (NULL != access && !strcmp(access, WRITE_ONLY)) {
+ LOGE("Provider has given [%s] permission only", access);
+ free(access);
+ return DATACONTROL_ERROR_PERMISSION_DENIED;
+ }
+ if (access)
+ free(access);
+
if (count_per_page > MAX_ROW_COUNT)
{
LOGE("Exceeds max row count per page.");
total_arg_count = column_count + DATACONTROL_SELECT_EXTRA_COUNT;
const char** arg_list = (const char**)malloc(total_arg_count * (sizeof(char *)));
- if (arg_list == NULL) {
- LOGE("out of memory");
+ if(arg_list == NULL) {
+ LOGE("OOM error");
bundle_free(b);
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
- LOGI("total arg count %d", total_arg_count);
+ SECURE_LOGI("total arg count %d", total_arg_count);
arg_list[0] = provider->data_id; // arg[0]: data ID
int i = 1;
- if (column_list)
- {
- char select_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
- ret = snprintf(select_column_count, MAX_LEN_DATACONTROL_COLUMN_COUNT, "%d", column_count);
- if(ret < 0)
- {
- LOGE("unable to convert select col count to string: %d", errno);
- free(arg_list);
- bundle_free(b);
- return DATACONTROL_ERROR_IO_ERROR;
- }
+ char select_column_count[MAX_LEN_DATACONTROL_COLUMN_COUNT] = {0, };
+ ret = snprintf(select_column_count, MAX_LEN_DATACONTROL_COLUMN_COUNT, "%d", column_count);
+ if(ret < 0)
+ {
+ LOGE("unable to convert select col count to string: %d", errno);
+ free(arg_list);
+ bundle_free(b);
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
- arg_list[i] = select_column_count; // arg[1]: selected column count
+ arg_list[i] = select_column_count; // arg[1]: selected column count
- ++i;
- int select_col = 0;
- while (select_col < column_count)
- {
- arg_list[i++] = column_list[select_col++];
- }
+ ++i;
+ int select_col = 0;
+ while (select_col < column_count)
+ {
+ arg_list[i++] = column_list[select_col++];
}
if (where) // arg: where clause
int fd = 0;
char *provider_pkgid = __get_provider_pkgid(provider->provider_id);
+ if (provider_pkgid == NULL) {
+ LOGE("Unable to get the provider pkgid");
+ return DATACONTROL_ERROR_IO_ERROR;
+ }
ret = security_server_shared_file_open(update_map_file, provider_pkgid, &fd);
if (ret == SECURITY_SERVER_API_ERROR_FILE_EXIST) {