diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-19 18:06:55 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-19 18:09:57 +0200 |
commit | 6d544984f2418ea34caab4c433580487b760362a (patch) | |
tree | cf0510b97a6495587c87598a70bf8761189f5c32 /lib/libalpm/add.c | |
parent | 9934b3bd345011eef6a96249d8d90de594c04cd0 (diff) | |
download | pacman-6d544984f2418ea34caab4c433580487b760362a.tar.gz pacman-6d544984f2418ea34caab4c433580487b760362a.tar.xz |
Be more robust when copying package data
This changes the signature of _alpm_pkg_dup() to return an integer error
code and provide the new package in a passed pointer argument. All
callers are now more robust with checking the return value of this
function to ensure a fatal error did not occur.
We allow load failures to proceed as otherwise we have a chicken and egg
problem- if a 'desc' local database entry is missing, the best way of
restoring said file is `pacman -Sf --dbonly packagename`. This patch
fixes a segfault that was occurring in this case.
Fixes the segfault reported in FS#25667.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r-- | lib/libalpm/add.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 8bbf1574..cb8551e8 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -468,19 +468,22 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg, is_upgrade = 1; /* we'll need to save some record for backup checks later */ - oldpkg = _alpm_pkg_dup(local); + if(_alpm_pkg_dup(local, &oldpkg) == -1) { + ret = -1; + goto cleanup; + } - EVENT(trans, ALPM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg); + EVENT(trans, ALPM_TRANS_EVT_UPGRADE_START, newpkg, local); _alpm_log(handle, ALPM_LOG_DEBUG, "upgrading package %s-%s\n", newpkg->name, newpkg->version); /* copy over the install reason */ - newpkg->reason = alpm_pkg_get_reason(oldpkg); + newpkg->reason = alpm_pkg_get_reason(local); /* pre_upgrade scriptlet */ if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) { _alpm_runscriptlet(handle, newpkg->origin_data.file, - "pre_upgrade", newpkg->version, oldpkg->version); + "pre_upgrade", newpkg->version, local->version); } } else { is_upgrade = 0; |