From 53de9e531bfd5ce84e598d5b4b7c27a6ef4b4dfb Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 10 Oct 2009 08:44:37 +0200 Subject: [PATCH] lib/unpack.c: fix a NULL pointer deref when checking configuration files exists or not while unpacking. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091010064437-9121w162sy8ilpim --- lib/unpack.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/unpack.c b/lib/unpack.c index 4c84f976..2cf3b39d 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -160,24 +160,26 @@ install_config_file(prop_dictionary_t d, struct archive_entry *entry, forigd = prop_dictionary_internalize_from_file(buf); free(buf); - if (forigd != NULL) { - iter2 = xbps_get_array_iter_from_dict(forigd, "conf_files"); - if (iter2 != NULL) { - while ((obj2 = prop_object_iterator_next(iter2))) { - prop_dictionary_get_cstring_nocopy(obj2, - "file", &cffile); - if (strstr(archive_entry_pathname(entry), - cffile)) { - prop_dictionary_get_cstring(obj2, - "sha256", &sha256_orig); - break; - } - } - prop_object_iterator_release(iter2); - } - prop_object_release(forigd); + if (forigd == NULL) { + install_new = true; + goto out; } + iter2 = xbps_get_array_iter_from_dict(forigd, "conf_files"); + if (iter2 != NULL) { + while ((obj2 = prop_object_iterator_next(iter2))) { + prop_dictionary_get_cstring_nocopy(obj2, + "file", &cffile); + if (strstr(archive_entry_pathname(entry), cffile)) { + prop_dictionary_get_cstring(obj2, "sha256", + &sha256_orig); + break; + } + } + prop_object_iterator_release(iter2); + } + prop_object_release(forigd); + /* * Compare original, installed and new hash for current file. */ @@ -268,6 +270,7 @@ install_config_file(prop_dictionary_t d, struct archive_entry *entry, } } +out: if (install_new) set_extract_flags(flags); if (sha256_orig)