return NULL;
}
- application_x* app = (application_x*)::malloc(sizeof(application_x));
- pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::malloc(sizeof(pkgmgr_appinfo_x));
- app_info_s* appinfo = (app_info_s*)::malloc(sizeof(struct app_info_s));
+ application_x* app = (application_x*)::calloc(1, sizeof(application_x));
+ if (app == NULL) {
+ return NULL;
+ }
+
+ pkgmgr_appinfo_x* pkgappinfo = (pkgmgr_appinfo_x*)::calloc(1, sizeof(pkgmgr_appinfo_x));
+ if (pkgappinfo == NULL) {
+ free(app);
+ return NULL;
+ }
+
+ app_info_s* appinfo = (app_info_s*)::calloc(1, sizeof(struct app_info_s));
+ if (appinfo == NULL) {
+ free(app);
+ free(pkgappinfo);
+ return NULL;
+ }
- ::memset(appinfo, 0, sizeof(app_info_s));
appinfo->app_id = ::strdup(info.id.c_str());
appinfo->pkg_app_info = pkgappinfo;
- ::memset(pkgappinfo, 0, sizeof(pkgmgr_appinfo_x));
pkgappinfo->package = ::strdup(info.package.c_str());
pkgappinfo->locale = ::strdup(info.locale.c_str());
pkgappinfo->app_component = info.componentType;
pkgappinfo->app_info = app;
- ::memset(app, 0, sizeof(application_x));
app->appid = ::strdup(info.id.c_str());
app->nodisplay = ::strdup(info.isNoDisplayed? "true":"false");
app->taskmanage = ::strdup(info.isTaskManaged? "true":"false");
app->type = ::strdup(info.type.c_str());
icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x));
- icon->text = ::strdup(info.icon.c_str());
- icon->lang = ::strdup(info.locale.c_str());
- app->icon = ::g_list_append(NULL, icon);
+ if (icon != NULL) {
+ icon->text = ::strdup(info.icon.c_str());
+ icon->lang = ::strdup(info.locale.c_str());
+ app->icon = ::g_list_append(NULL, icon);
+ }
label_x* label = (label_x*)::calloc(1, sizeof(label_x));
- label->text = ::strdup(info.label.c_str());
- label->lang = ::strdup(info.locale.c_str());
- app->label = ::g_list_append(NULL, label);
+ if (label != NULL) {
+ label->text = ::strdup(info.label.c_str());
+ label->lang = ::strdup(info.locale.c_str());
+ app->label = ::g_list_append(NULL, label);
+ }
return reinterpret_cast<app_info_h>(appinfo);
}
}
package_x* package = (package_x*)::calloc(1, sizeof(package_x));
+ if (package == NULL) {
+ return NULL;
+ }
+
pkgmgr_pkginfo_x* pkginfo = (pkgmgr_pkginfo_x*)::calloc(1, sizeof(pkgmgr_pkginfo_x));
+ if (pkginfo == NULL) {
+ free(package);
+ return NULL;
+ }
+
package_info_s* packageinfo = (package_info_s*)::calloc(1, sizeof(package_info_s));
+ if (packageinfo == NULL) {
+ free(package);
+ free(pkginfo);
+ return NULL;
+ }
packageinfo->package = ::strdup(info.id.c_str());
packageinfo->pkgmgr_pkginfo = pkginfo;
package->api_version = ::strdup(info.apiVersion.c_str());
icon_x* icon = (icon_x*)::calloc(1, sizeof(icon_x));
- icon->text = ::strdup(info.icon.c_str());
- icon->lang = ::strdup(info.locale.c_str());
- package->icon = ::g_list_append(NULL, icon);
+ if (icon != NULL) {
+ icon->text = ::strdup(info.icon.c_str());
+ icon->lang = ::strdup(info.locale.c_str());
+ package->icon = ::g_list_append(NULL, icon);
+ }
label_x* label = (label_x*)::calloc(1, sizeof(label_x));
- label->text = ::strdup(info.label.c_str());
- label->lang = ::strdup(info.locale.c_str());
- package->label = ::g_list_append(NULL, label);
+ if (label != NULL) {
+ label->text = ::strdup(info.label.c_str());
+ label->lang = ::strdup(info.locale.c_str());
+ package->label = ::g_list_append(NULL, label);
+ }
description_x* desc = (description_x*)::calloc(1, sizeof(description_x));
- desc->text = ::strdup(info.description.c_str());
- desc->lang = ::strdup(info.locale.c_str());
- package->description = ::g_list_append(NULL, desc);
+ if (desc != NULL) {
+ desc->text = ::strdup(info.description.c_str());
+ desc->lang = ::strdup(info.locale.c_str());
+ package->description = ::g_list_append(NULL, desc);
+ }
author_x* author = (author_x*)::calloc(1, sizeof(author_x));
- author->text = ::strdup(info.author.name.c_str());
- author->email = ::strdup(info.author.email.c_str());
- author->href = ::strdup(info.author.href.c_str());
- author->lang = ::strdup(info.locale.c_str());
- package->author = ::g_list_append(NULL, author);
+ if (author != NULL) {
+ author->text = ::strdup(info.author.name.c_str());
+ author->email = ::strdup(info.author.email.c_str());
+ author->href = ::strdup(info.author.href.c_str());
+ author->lang = ::strdup(info.locale.c_str());
+ package->author = ::g_list_append(NULL, author);
+ }
return reinterpret_cast<package_info_h>(packageinfo);
}
char* ret, *buf = malloc(bufsize * sizeof(char));
+ if (buf == NULL) {
+ return NULL;
+ }
+
getpwuid_r(getuid(), &pwd, buf, bufsize, &result);
if (result == NULL) {
ret = NULL;
unsigned char keyBuffer[ECRYPTFS_MAX_KEY_SIZE+1];
- ecryptfs_payload* authToken = (ecryptfs_payload *)::malloc(sizeof(ecryptfs_payload));
+ ecryptfs_payload* authToken = new ecryptfs_payload();
if (authToken == NULL) {
return NULL;
}
"user",
signature,
0);
- if (rc == -1 && errno != ENOKEY) {
- ERROR("Failed to find key");
- return -1;
- }
+
if (rc == -1) {
+ if (errno != ENOKEY) {
+ ERROR("Failed to find key");
+ delete authTok;
+ return -1;
+ }
+
rc = KernelKeyRing::add("user",
signature,
(void*)authTok,
sizeof(ecryptfs_payload),
KEY_SPEC_USER_KEYRING);
+
if (rc == -1) {
ERROR("Failed to add key");
return -1;
"smackfsroot=*,smackfsdef=*",
ECRYPTFS_MAX_KEY_SIZE, signature);
+ delete authTok;
+
rc = ::mount(src.c_str(), src.c_str(), "ecryptfs", MS_NODEV, ecryptfsOpts);
if (rc != 0) {
ERROR(runtime::GetSystemErrorMessage());