#define CRYPTO_ERROR -1
#define CRYPTO_ERROR_NONE 0
#define CRYPTO_ERROR_INVALID_PARAMETER TIZEN_ERROR_INVALID_PARAMETER
+#define CRYPTO_ERROR_OUT_OF_MEMORY TIZEN_ERROR_OUT_OF_MEMORY
#define ACCESS_TOKEN_ALIAS "access_token"
// assing a enough memory for decryption.
ciphertext = (unsigned char*) malloc(data_len + 32);
+ if (ciphertext == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return CRYPTO_ERROR_OUT_OF_MEMORY;
+ }
+
ACCOUNT_MEMSET(ciphertext, 0, data_len + 32);
_INFO("before EVP_CIPHER_CTX_new");
// assing a enough memory for decryption.
plaintext = (unsigned char*) malloc(data_len);
+ if (plaintext == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return CRYPTO_ERROR_OUT_OF_MEMORY;
+ }
+
ACCOUNT_MEMSET(plaintext, 0, data_len);
_INFO("before EVP_CIPHER_CTX_new");
if (!g_strcmp0(cmdline, EMAIL_SERVICE_CMDLINE)) {
appid_ret = _account_dup_text(EMAIL_APPID);
_ACCOUNT_FREE(cmdline);
+
+ if (appid_ret == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return NULL;
+ }
+
return appid_ret;
} else {
ACCOUNT_DEBUG("No app id\n");
return NULL;
}
}
- return _account_dup_text(appid);
+
+ appid_ret = _account_dup_text(appid);
+ if (appid_ret == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ }
+
+ return appid_ret;
}
}
item = _account_dup_text(appid);
+ if (item == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return _ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
+
*appid_list = g_slist_append(*appid_list, item);
- return 0;
+ return _ACCOUNT_ERROR_NONE;
}
static int _account_type_query_app_id_exist(sqlite3 *account_db_handle, const char* app_id)
if(!strcmp(appid, "com.samsung.setting")){
ACCOUNT_DEBUG("Setting exception\n");
*verified_appid = _account_dup_text("com.samsung.setting");
+ if (*verified_appid == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return _ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
return _ACCOUNT_ERROR_NONE;
}
if(!strcmp(appid, "com.samsung.samsung-account-front")){
ACCOUNT_DEBUG("Setting exception\n");
*verified_appid = _account_dup_text("com.samsung.samsung-account-front");
+ if (*verified_appid == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return _ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
return _ACCOUNT_ERROR_NONE;
}
if(tmp) {
if(_account_type_query_app_id_exist_from_all_db(account_user_db, account_global_db, tmp) == _ACCOUNT_ERROR_NONE) {
*verified_appid = _account_dup_text(tmp);
+ if (*verified_appid == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ error_code = _ACCOUNT_ERROR_OUT_OF_MEMORY;
+ break;
+ }
error_code = _ACCOUNT_ERROR_NONE;
_ACCOUNT_FREE(tmp);
break;
static bool _account_add_capability_to_account_cb(const char* capability_type, int capability_value, account_s *account)
{
account_capability_s *cap_data = (account_capability_s*)malloc(sizeof(account_capability_s));
-
- if (cap_data == NULL)
+ if (cap_data == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
return FALSE;
+ }
+
ACCOUNT_MEMSET(cap_data, 0, sizeof(account_capability_s));
cap_data->type = _account_dup_text(capability_type);
+ if (cap_data->type == NULL) {
+ ACCOUNT_FATAL("_account_add_capability_to_account_cb :: malloc fail");
+ return FALSE;
+ }
+
cap_data->value = capability_value;
_INFO("cap_data->type = %s, cap_data->value = %d", cap_data->type, cap_data->value);
account_custom_s *custom_data = (account_custom_s*)malloc(sizeof(account_custom_s));
if (custom_data == NULL) {
- ACCOUNT_DEBUG("_account_add_custom_to_account_cb :: malloc fail\n");
+ ACCOUNT_FATAL("_account_add_custom_to_account_cb :: malloc fail\n");
return FALSE;
}
ACCOUNT_MEMSET(custom_data, 0, sizeof(account_custom_s));
custom_data->account_id = account->id;
custom_data->app_id = _account_dup_text(account->package_name);
+ if (custom_data->app_id == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return FALSE;
+ }
+
custom_data->key = _account_dup_text(key);
+ if (custom_data->key == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return FALSE;
+ }
+
custom_data->value = _account_dup_text(value);
+ if (custom_data->value == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return FALSE;
+ }
+
_INFO("custom_data->key = %s, custom_data->value = %s", custom_data->key, custom_data->value);
account->custom_list = g_slist_append(account->custom_list, (gpointer)custom_data);
current_appid = _account_get_current_appid(pid, uid);
package_name_temp = _account_dup_text(package_name);
+ if (package_name_temp == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return _ACCOUNT_ERROR_OUT_OF_MEMORY;
+ }
ACCOUNT_DEBUG( "DELETE: current_appid[%s], package_name[%s]", current_appid, package_name_temp);
g_variant_get (variant, "(sss)", &app_id, &label, &locale);
label_s* label_data = (label_s*) calloc(1, sizeof(label_s));
-
if( label_data == NULL ) {
- _ERR("provider_feature_s calloc failed - out of memory.");
+ ACCOUNT_FATAL("label_s calloc failed - out of memory.");
+ g_free(app_id);
+ g_free(label);
+ g_free(locale);
return NULL;
}
label_data->app_id = g_strdup(app_id);
+
label_data->label = g_strdup(label);
+
label_data->locale = g_strdup(locale);
- g_free (app_id);
- g_free (label);
- g_free (locale);
+ g_free(app_id);
+ g_free(label);
+ g_free(locale);
return label_data;
}
g_variant_get (variant, "(ss)", &key, &app_id);
provider_feature_s* provider_feature_data = (provider_feature_s*) calloc(1, sizeof(provider_feature_s));
-
- if( provider_feature_data == NULL ) {
+ if (provider_feature_data == NULL) {
_ERR("provider_feature_s calloc failed - out of memory.");
return NULL;
}
provider_feature_data->key = g_strdup(key);
+
provider_feature_data->app_id = g_strdup(app_id);
g_free (key);
}
account_s* account = (account_s*)calloc(1, sizeof(account_s));
- if (account == NULL)
- {
- _ERR("Out of memory");
+ if (account == NULL) {
+ _ERR("account_s calloc failed - out of memory");
return NULL;
}
while (g_variant_iter_loop (&iter, "a{sv}", &iter_row))
{
account_s* account = (account_s*)calloc(1, sizeof(account_s));
+ if (account == NULL) {
+ ACCOUNT_FATAL("account_s calloc failed - out of memory.");
+ break;
+ }
while (g_variant_iter_loop(iter_row, "{sv}", &key, &value))
{
_INFO("create_empty_account_instance start");
account_s *data = (account_s*)malloc(sizeof(account_s));
-
- if (data == NULL)
- {
- ACCOUNT_ERROR("Memory Allocation Failed");
+ if (data == NULL) {
+ ACCOUNT_ERROR("account_s malloc failed - out of memory");
return NULL;
}
{
_INFO("create_empty_account_type_instance start");
account_type_s *data = (account_type_s*)malloc(sizeof(account_type_s));
-
- if (data == NULL)
- {
- ACCOUNT_ERROR("Memory Allocation Failed");
+ if (data == NULL) {
+ ACCOUNT_ERROR("account_type_s malloc failed - out of memory");
return NULL;
}
}
account_type_s* account_type = (account_type_s*)calloc(1, sizeof(account_type_s));
- if (account_type == NULL)
- {
- _ERR("Out of memory");
+ if (account_type == NULL) {
+ ACCOUNT_FATAL("account_type_s calloc failed - out of memory");
return NULL;
}
while (g_variant_iter_loop (&iter, "a{sv}", &iter_row))
{
account_capability_s* account_capability = (account_capability_s*)calloc(1, sizeof(account_capability_s));
+ if (account_capability == NULL) {
+ ACCOUNT_FATAL("account_capability_s calloc Failed - out of memory");
+ break;
+ }
while (g_variant_iter_loop(iter_row, "{sv}", &key, &value))
{
while (g_variant_iter_loop (&iter, "a{sv}", &iter_row))
{
account_custom_s* account_custom = (account_custom_s*)calloc(1, sizeof(account_custom_s));
+ if (account_custom == NULL) {
+ ACCOUNT_FATAL("account_custom_s calloc failed - out of memory");
+ break;
+ }
while (g_variant_iter_loop(iter_row, "{sv}", &key, &value))
{
// gchar* var_type = g_variant_print (variant, TRUE);
// _INFO("var_type = %s", var_type);
- g_variant_iter_init (&iter, variant);
+ user_data_int = (int*)calloc(USER_INT_CNT, sizeof(int)*USER_INT_CNT);
+ if (user_data_int == NULL) {
+ ACCOUNT_FATAL("user_data_int_array calloc failed - out of memory");
+ return NULL;
+ }
- user_data_int = (int*)calloc(USER_INT_CNT, sizeof(int));
+ g_variant_iter_init (&iter, variant);
for(i=0; i<USER_INT_CNT; i++)
{
// gchar* var_type = g_variant_print (variant, TRUE);
// _INFO("var_type = %s", var_type);
- g_variant_iter_init (&iter, variant);
+ user_data_txts = (char**)calloc(USER_TXT_CNT, sizeof(char*)*USER_TXT_CNT);
+ if (user_data_txts == NULL) {
+ ACCOUNT_FATAL("user_data_txt_array calloc failed - out of memory");
+ return NULL;
+ }
- user_data_txts = (char**)calloc(USER_TXT_CNT, sizeof(char*));
+ g_variant_iter_init (&iter, variant);
for(i=0; i<USER_TXT_CNT; i++)
{
_INFO("before mkey_buffer->size=[%d]", mkey_buffer->size);
*mkey_len = mkey_buffer->size;
*mkey = (unsigned char *) malloc((*mkey_len)+1);
+ if (*mkey == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return CKMC_ERROR_OUT_OF_MEMORY;
+ }
+
memset(*mkey, 0, (*mkey_len)+1);
memcpy(*mkey, mkey_buffer->data, *mkey_len);
// (*mkey)[*mkey_len] = '\0';
_INFO("start _create_app_mkey");
random = (unsigned char *) malloc(MKEY_LEN);
+ if (random == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return CKMC_ERROR_OUT_OF_MEMORY;
+ }
+
_INFO("before _get_random");
ret = _get_random(MKEY_LEN, &random);
if(CKMC_ERROR_NONE != ret) {
*dek_len = dek_buffer->size;
*dek = (unsigned char *) malloc((*dek_len)+1);
+ if (*dek == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return CKMC_ERROR_OUT_OF_MEMORY;
+ }
+
_INFO("before memcpy dek_buffer");
memcpy(*dek, dek_buffer->data, (*dek_len)+1);
_INFO("before dek_buffer free");
sprintf(alias, "%s%s", ACCOUNT_MANAGER_DEK_ALIAS_PFX, pkg_id);
random = (unsigned char *) malloc(DEK_LEN);
+ if (random == NULL) {
+ ACCOUNT_FATAL("Memory Allocation Failed");
+ return CKMC_ERROR_OUT_OF_MEMORY;
+ }
+
ret = _get_random(DEK_LEN, &random);
if(CKMC_ERROR_NONE != ret) {
return CKMC_ERROR_UNKNOWN;