X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-install.c;h=31c9e9105a10a3c1d922e846bdcb436bc8b754da;hb=bfc9c138b1a9e87f9d387e2f900c14807c9da9b9;hp=550135cdd4ab2b5d77d92db61f09df11e80e835e;hpb=9680a57f258d4118416104c224153a0292b7328e;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-install.c b/src/wgtpkg-install.c index 550135c..31c9e91 100644 --- a/src/wgtpkg-install.c +++ b/src/wgtpkg-install.c @@ -81,13 +81,16 @@ static int check_valid_string(const char *value, const char *name) static int check_temporary_constraints(const struct wgt_desc *desc) { - int result = check_valid_string(desc->id, "id"); + int result; + + result = check_valid_string(desc->id, "id"); result |= check_valid_string(desc->version, "version"); result |= check_valid_string(desc->ver, "ver"); result |= check_defined(desc->icons, "icon"); result |= check_defined(desc->content_src, "content"); if (result) return result; + if (desc->icons->next) { ERROR("widget has more than one icon defined (temporary constraints)"); errno = EINVAL; @@ -141,19 +144,24 @@ static int check_widget(const struct wgt_desc *desc) return result; } -static int move_widget(const char *root, const struct wgt_desc *desc, int force) +static int get_target_directory(char target[PATH_MAX], const char *root, const struct wgt_desc *desc) { - char newdir[PATH_MAX]; int rc; - rc = snprintf(newdir, sizeof newdir, "%s/%s/%s", root, desc->id, desc->ver); - if (rc >= (int)sizeof newdir) { - ERROR("path too long in move_widget"); + rc = snprintf(target, PATH_MAX, "%s/%s/%s", root, desc->id, desc->ver); + if (rc < PATH_MAX) + rc = 0; + else { + ERROR("path too long"); errno = EINVAL; - return -1; + rc = -1; } + return rc; +} - return move_workdir(newdir, 1, force); +static int move_widget_to(const char *destdir, int force) +{ + return move_workdir(destdir, 1, force); } static int install_icon(const struct wgt_desc *desc) @@ -269,6 +277,7 @@ struct wgt_info *install_widget(const char *wgtfile, const char *root, int force { struct wgt_info *ifo; const struct wgt_desc *desc; + char installdir[PATH_MAX]; NOTICE("-- INSTALLING widget %s to %s --", wgtfile, root); @@ -294,7 +303,10 @@ struct wgt_info *install_widget(const char *wgtfile, const char *root, int force if (check_widget(desc)) goto error3; - if (move_widget(root, desc, force)) + if (get_target_directory(installdir, root, desc)) + goto error3; + + if (move_widget_to(installdir, force)) goto error3; if (install_icon(desc))