From 3de4aca12928f8581e3b4b2602caa85f9e230d47 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 23 Nov 2009 00:28:23 +0000 Subject: [PATCH] xbps_register_pkg: check that required objs are there! --HG-- extra : convert_revision : xtraeme%40gmail.com-20091123002823-o49jdxxwbgvo31us --- lib/register.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/register.c b/lib/register.c index 282a2439..7401d33a 100644 --- a/lib/register.c +++ b/lib/register.c @@ -44,10 +44,22 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) if (plist == NULL) return EINVAL; - prop_dictionary_get_cstring_nocopy(pkgrd, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version); - prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); - prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver); + if (!prop_dictionary_get_cstring_nocopy(pkgrd, "pkgname", &pkgname)) { + free(plist); + return EINVAL; + } + if (!prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version)) { + free(plist); + return EINVAL; + } + if (!prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc)) { + free(plist); + return EINVAL; + } + if (!prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver)) { + free(plist); + return EINVAL; + } dict = prop_dictionary_internalize_from_file(plist); if (dict != NULL) {