}
strncpy(temp, path, PATH_MAX - 1);
if (strchr(path, '/') == NULL) {
- getcwd(abs, PATH_MAX - 1);
- if (abs[0] == '\0') {
+ if (getcwd(abs, PATH_MAX - 1) == NULL || abs[0] == '\0') {
printf("getcwd() failed\n");
return -1;
}
}
if (strncmp(path, "./", 2) == 0) {
ptr = temp;
- getcwd(abs, PATH_MAX - 1);
- if (abs[0] == '\0') {
+ if (getcwd(abs, PATH_MAX - 1) == NULL || abs[0] == '\0') {
printf("getcwd() failed\n");
return -1;
}
return 0;
}
-static char *__get_pkgid_from_tep(const char *filename)
-{
- char *pkg_type = NULL;
- char pkg_file[PATH_MAX] = { '\0', };
- char *tmp = NULL;
- char *pkgid = NULL;
- size_t pkgid_len = 0;
-
- if (strrchr(filename, '/')) {
- strncpy(pkg_file, strrchr(filename, '/') + 1, PATH_MAX - 1);
- } else {
- strncpy(pkg_file, filename, PATH_MAX - 1);
- }
-
- pkg_type = strrchr(pkg_file, '.');
- if (pkg_type == NULL) {
- printf("pkg_type is null[%s]\n", filename);
- return NULL;
- } else {
- pkg_type++;
- }
-
- if (strcmp(pkg_type, "tep") != 0)
- return NULL;
-
- tmp = strrchr(pkg_file, '-');
- if (tmp == NULL || strlen(tmp) == 0) {
- printf("Invalid tep file name!!!\n");
- return NULL;
- }
-
- pkgid_len = tmp - pkg_file;
- pkgid = calloc(1, pkgid_len + 1);
- if (pkgid == NULL) {
- printf("Insufficient Memory\n");
- return NULL;
- }
- memcpy((void *)pkgid, (const void *)pkg_file, pkgid_len);
-
- return pkgid;
-}
-
static void __print_usage()
{
printf("\nPackage Manager Tool Version: %s\n\n", PKG_TOOL_VERSION);
char pkg_old[PATH_MAX] = {0, };
char pkg_new[PATH_MAX] = {0, };
bool blacklist;
- pkgmgrinfo_pkginfo_h pkginfo;
#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
if (optarg) {
strncpy(data.pkg_old, optarg, PATH_MAX - 1);
}
- realpath(data.pkg_old, data.resolved_path_pkg_old);
+ if (realpath(data.pkg_old, data.resolved_path_pkg_old) == NULL) {
+ printf("failed to set realpath\n");
+ return -1;
+ }
printf("pkg_old abs path is %s\n", data.resolved_path_pkg_old);
break;
if (optarg) {
strncpy(data.pkg_new, optarg, PATH_MAX - 1);
}
- realpath(data.pkg_new, data.resolved_path_pkg_new);
+ if (realpath(data.pkg_new, data.resolved_path_pkg_new) == NULL) {
+ printf("failed to set realpath\n");
+ return -1;
+ }
printf("pkg_new abs path is %s\n", data.resolved_path_pkg_new);
break;
strncpy(data.delta_pkg, optarg, PATH_MAX - 1);
}
printf("delta_pkg is %s\n", data.delta_pkg);
- realpath(data.delta_pkg, data.resolved_path_delta_pkg);
+ if (realpath(data.delta_pkg, data.resolved_path_delta_pkg) == NULL) {
+ printf("failed to set realpath\n");
+ return -1;
+ }
printf("delta_pkg abs path is %s\n",data.resolved_path_delta_pkg);
break;
case 'd': /* descriptor path */