aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-02-15 21:19:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-02-15 21:19:50 +0000
commit7fd00cbff72f7ac46eddef7366e32780cb364fae (patch)
tree28447048eaa4fb3ac19ad3ab2a7b2780bc52edb1
parent4998c818919477d90674a3f220e7407c26da17f9 (diff)
downloadbusybox-w32-7fd00cbff72f7ac46eddef7366e32780cb364fae.tar.gz
busybox-w32-7fd00cbff72f7ac46eddef7366e32780cb364fae.tar.bz2
busybox-w32-7fd00cbff72f7ac46eddef7366e32780cb364fae.zip
dpkg: fix segfault on "dpkg -i"
-rw-r--r--archival/dpkg.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 5c69d9c64..c86c583ab 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1586,21 +1586,19 @@ int dpkg_main(int argc, char **argv)
1586 OPT_purge = 0x10, 1586 OPT_purge = 0x10,
1587 OPT_remove = 0x20, 1587 OPT_remove = 0x20,
1588 OPT_unpack = 0x40, 1588 OPT_unpack = 0x40,
1589 REQ_package_name = 0x8000,
1590 REQ_filename = 0x4000,
1591 }; 1589 };
1592 1590
1593 opt = getopt32(argc, argv, "CF:ilPru", &str_f); 1591 opt = getopt32(argc, argv, "CF:ilPru", &str_f);
1594 if (opt & OPT_configure) opt |= REQ_package_name; // -C 1592 //if (opt & OPT_configure) ... // -C
1595 if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg) 1593 if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
1596 if (strcmp(str_f, "depends")) 1594 if (strcmp(str_f, "depends"))
1597 opt &= ~OPT_force_ignore_depends; 1595 opt &= ~OPT_force_ignore_depends;
1598 } 1596 }
1599 if (opt & OPT_install) opt |= REQ_filename; // -i 1597 //if (opt & OPT_install) ... // -i
1600 //if (opt & OPT_list_installed) ... // -l 1598 //if (opt & OPT_list_installed) ... // -l
1601 if (opt & OPT_purge) opt |= REQ_package_name; // -P 1599 //if (opt & OPT_purge) ... // -P
1602 if (opt & OPT_remove) opt |= REQ_package_name; // -r 1600 //if (opt & OPT_remove) ... // -r
1603 if (opt & OPT_unpack) opt |= REQ_filename; // -u (--unpack in official dpkg) 1601 //if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
1604 argc -= optind; 1602 argc -= optind;
1605 argv += optind; 1603 argv += optind;
1606 /* check for non-option argument if expected */ 1604 /* check for non-option argument if expected */
@@ -1623,9 +1621,10 @@ int dpkg_main(int argc, char **argv)
1623 /* Read arguments and store relevant info in structs */ 1621 /* Read arguments and store relevant info in structs */
1624 while (*argv) { 1622 while (*argv) {
1625 /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */ 1623 /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
1626 deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2)); 1624 deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2));
1627 deb_file[deb_count] = xzalloc(sizeof(deb_file_t)); 1625 deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
1628 if (opt & REQ_filename) { 1626 if (opt & (OPT_install | OPT_unpack)) {
1627 /* -i/-u: require filename */
1629 archive_handle_t *archive_handle; 1628 archive_handle_t *archive_handle;
1630 llist_t *control_list = NULL; 1629 llist_t *control_list = NULL;
1631 1630
@@ -1648,7 +1647,7 @@ int dpkg_main(int argc, char **argv)
1648 deb_file[deb_count]->package = (unsigned) package_num; 1647 deb_file[deb_count]->package = (unsigned) package_num;
1649 1648
1650 /* Add the package to the status hashtable */ 1649 /* Add the package to the status hashtable */
1651 if (opt & (OPT_unpack|OPT_install)) { 1650 if (opt & (OPT_unpack | OPT_install)) {
1652 /* Try and find a currently installed version of this package */ 1651 /* Try and find a currently installed version of this package */
1653 status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]); 1652 status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
1654 /* If no previous entry was found initialise a new entry */ 1653 /* If no previous entry was found initialise a new entry */
@@ -1666,8 +1665,8 @@ int dpkg_main(int argc, char **argv)
1666 set_status(status_num, "reinstreq", 2); 1665 set_status(status_num, "reinstreq", 2);
1667 } 1666 }
1668 } 1667 }
1669 } 1668 } else if (opt & (OPT_configure | OPT_purge | OPT_remove)) {
1670 else if (opt & REQ_package_name) { 1669 /* -C/-p/-r: require package name */
1671 deb_file[deb_count]->package = search_package_hashtable( 1670 deb_file[deb_count]->package = search_package_hashtable(
1672 search_name_hashtable(argv[0]), 1671 search_name_hashtable(argv[0]),
1673 search_name_hashtable("ANY"), VER_ANY); 1672 search_name_hashtable("ANY"), VER_ANY);
@@ -1686,8 +1685,7 @@ int dpkg_main(int argc, char **argv)
1686 bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]); 1685 bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]);
1687 } 1686 }
1688 set_status(status_num, "deinstall", 1); 1687 set_status(status_num, "deinstall", 1);
1689 } 1688 } else if (opt & OPT_purge) {
1690 else if (opt & OPT_purge) {
1691 /* if package status is "conf-files" then its ok */ 1689 /* if package status is "conf-files" then its ok */
1692 if (strcmp(name_hashtable[state_status], "not-installed") == 0) { 1690 if (strcmp(name_hashtable[state_status], "not-installed") == 0) {
1693 bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]); 1691 bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]);
@@ -1698,6 +1696,8 @@ int dpkg_main(int argc, char **argv)
1698 deb_count++; 1696 deb_count++;
1699 argv++; 1697 argv++;
1700 } 1698 }
1699 if (!deb_count)
1700 bb_error_msg_and_die("no package files specified");
1701 deb_file[deb_count] = NULL; 1701 deb_file[deb_count] = NULL;
1702 1702
1703 /* Check that the deb file arguments are installable */ 1703 /* Check that the deb file arguments are installable */