summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c421
-rw-r--r--lib/libalpm/add.h2
-rw-r--r--lib/libalpm/alpm.c2
-rw-r--r--lib/libalpm/alpm.h26
-rw-r--r--lib/libalpm/alpm_list.c2
-rw-r--r--lib/libalpm/alpm_list.h2
-rw-r--r--lib/libalpm/backup.c9
-rw-r--r--lib/libalpm/backup.h2
-rw-r--r--lib/libalpm/be_local.c21
-rw-r--r--lib/libalpm/be_package.c7
-rw-r--r--lib/libalpm/be_sync.c6
-rw-r--r--lib/libalpm/conflict.c23
-rw-r--r--lib/libalpm/conflict.h2
-rw-r--r--lib/libalpm/db.c13
-rw-r--r--lib/libalpm/db.h2
-rw-r--r--lib/libalpm/delta.c26
-rw-r--r--lib/libalpm/delta.h2
-rw-r--r--lib/libalpm/deps.c38
-rw-r--r--lib/libalpm/deps.h2
-rw-r--r--lib/libalpm/diskspace.c8
-rw-r--r--lib/libalpm/diskspace.h2
-rw-r--r--lib/libalpm/dload.c4
-rw-r--r--lib/libalpm/dload.h2
-rw-r--r--lib/libalpm/error.c2
-rw-r--r--lib/libalpm/filelist.c2
-rw-r--r--lib/libalpm/filelist.h2
-rw-r--r--lib/libalpm/graph.c2
-rw-r--r--lib/libalpm/graph.h2
-rw-r--r--lib/libalpm/group.c2
-rw-r--r--lib/libalpm/group.h2
-rw-r--r--lib/libalpm/handle.c2
-rw-r--r--lib/libalpm/handle.h2
-rw-r--r--lib/libalpm/libarchive-compat.h2
-rw-r--r--lib/libalpm/log.c2
-rw-r--r--lib/libalpm/log.h2
-rw-r--r--lib/libalpm/package.c13
-rw-r--r--lib/libalpm/package.h4
-rw-r--r--lib/libalpm/pkghash.c2
-rw-r--r--lib/libalpm/pkghash.h2
-rw-r--r--lib/libalpm/remove.c2
-rw-r--r--lib/libalpm/remove.h2
-rw-r--r--lib/libalpm/signing.c2
-rw-r--r--lib/libalpm/signing.h2
-rw-r--r--lib/libalpm/sync.c8
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c4
-rw-r--r--lib/libalpm/trans.h2
-rw-r--r--lib/libalpm/util.c6
-rw-r--r--lib/libalpm/util.h2
-rw-r--r--lib/libalpm/version.c2
50 files changed, 329 insertions, 374 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 5e2d0a15..ed29e680 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -1,7 +1,7 @@
/*
* add.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -107,7 +107,7 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
}
static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
- struct archive_entry *entry, const char *filename, const char *origname)
+ struct archive_entry *entry, const char *filename)
{
int ret;
const int archive_flags = ARCHIVE_EXTRACT_OWNER |
@@ -120,13 +120,13 @@ static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
if(ret == ARCHIVE_WARN && archive_errno(archive) != ENOSPC) {
/* operation succeeded but a "non-critical" error was encountered */
_alpm_log(handle, ALPM_LOG_WARNING, _("warning given when extracting %s (%s)\n"),
- origname, archive_error_string(archive));
+ filename, archive_error_string(archive));
} else if(ret != ARCHIVE_OK) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not extract %s (%s)\n"),
- origname, archive_error_string(archive));
+ filename, archive_error_string(archive));
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: could not extract %s (%s)\n",
- origname, archive_error_string(archive));
+ filename, archive_error_string(archive));
return 1;
}
return 0;
@@ -144,49 +144,59 @@ static int try_rename(alpm_handle_t *handle, const char *src, const char *dest)
return 0;
}
+static int extract_db_file(alpm_handle_t *handle, struct archive *archive,
+ struct archive_entry *entry, alpm_pkg_t *newpkg, const char *entryname)
+{
+ char filename[PATH_MAX]; /* the actual file we're extracting */
+ const char *dbfile;
+ if(strcmp(entryname, ".INSTALL") == 0) {
+ dbfile = "install";
+ } else if(strcmp(entryname, ".CHANGELOG") == 0) {
+ dbfile = "changelog";
+ } else if(strcmp(entryname, ".MTREE") == 0) {
+ dbfile = "mtree";
+ } else if(*entryname == '.') {
+ /* reserve all files starting with '.' for future possibilities */
+ _alpm_log(handle, ALPM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
+ archive_read_data_skip(archive);
+ return 0;
+ }
+ archive_entry_set_perm(entry, 0644);
+ snprintf(filename, PATH_MAX, "%s%s-%s/%s",
+ _alpm_db_path(handle->db_local), newpkg->name, newpkg->version, dbfile);
+ return perform_extraction(handle, archive, entry, filename);
+}
+
static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t *newpkg, alpm_pkg_t *oldpkg)
{
- const char *entryname;
- mode_t entrymode;
+ const char *entryname = archive_entry_pathname(entry);
+ mode_t entrymode = archive_entry_mode(entry);
+ alpm_backup_t *backup = _alpm_needbackup(entryname, newpkg);
char filename[PATH_MAX]; /* the actual file we're extracting */
int needbackup = 0, notouch = 0;
const char *hash_orig = NULL;
- char *entryname_orig = NULL;
int errors = 0;
+ struct stat lsbuf;
+ size_t filename_len;
- entryname = archive_entry_pathname(entry);
- entrymode = archive_entry_mode(entry);
+ if(*entryname == '.') {
+ return extract_db_file(handle, archive, entry, newpkg, entryname);
+ }
- if(strcmp(entryname, ".INSTALL") == 0) {
- /* the install script goes inside the db */
- snprintf(filename, PATH_MAX, "%s%s-%s/install",
- _alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
- archive_entry_set_perm(entry, 0644);
- } else if(strcmp(entryname, ".CHANGELOG") == 0) {
- /* the changelog goes inside the db */
- snprintf(filename, PATH_MAX, "%s%s-%s/changelog",
- _alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
- archive_entry_set_perm(entry, 0644);
- } else if(strcmp(entryname, ".MTREE") == 0) {
- /* the mtree file goes inside the db */
- snprintf(filename, PATH_MAX, "%s%s-%s/mtree",
- _alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
- archive_entry_set_perm(entry, 0644);
- } else if(*entryname == '.') {
- /* for now, ignore all files starting with '.' that haven't
- * already been handled (for future possibilities) */
- _alpm_log(handle, ALPM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
- archive_read_data_skip(archive);
+ if (!alpm_filelist_contains(&newpkg->files, entryname)) {
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("file not found in file list for package %s. skipping extraction of %s\n"),
+ newpkg->name, entryname);
return 0;
- } else {
- if (!alpm_filelist_contains(&newpkg->files, entryname)) {
- _alpm_log(handle, ALPM_LOG_WARNING, _("file not found in file list for package %s. skipping extraction of %s\n"),
- newpkg->name, entryname);
- return 0;
- }
- /* build the new entryname relative to handle->root */
- snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
+ }
+
+ /* build the new entryname relative to handle->root */
+ filename_len = snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
+ if(filename_len >= PATH_MAX) {
+ _alpm_log(handle, ALPM_LOG_ERROR,
+ _("unable to extract %s%s: path too long"), handle->root, entryname);
+ return 1;
}
/* if a file is in NoExtract then we never extract it */
@@ -214,123 +224,124 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
* 6- skip extraction, dir already exists.
*/
- struct stat lsbuf;
if(llstat(filename, &lsbuf) != 0) {
/* cases 1,2: file doesn't exist, skip all backup checks */
- } else {
- if(S_ISDIR(lsbuf.st_mode)) {
- if(S_ISDIR(entrymode)) {
+ } else if(S_ISDIR(lsbuf.st_mode) && S_ISDIR(entrymode)) {
#if 0
- uid_t entryuid = archive_entry_uid(entry);
- gid_t entrygid = archive_entry_gid(entry);
+ uid_t entryuid = archive_entry_uid(entry);
+ gid_t entrygid = archive_entry_gid(entry);
#endif
- /* case 6: existing dir, ignore it */
- if(lsbuf.st_mode != entrymode) {
- /* if filesystem perms are different than pkg perms, warn user */
- mode_t mask = 07777;
- _alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
- "filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
- entrymode & mask);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: directory permissions differ on %s\n"
- "filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
- entrymode & mask);
- }
+ /* case 6: existing dir, ignore it */
+ if(lsbuf.st_mode != entrymode) {
+ /* if filesystem perms are different than pkg perms, warn user */
+ mode_t mask = 07777;
+ _alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
+ "filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
+ entrymode & mask);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: directory permissions differ on %s\n"
+ "filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
+ entrymode & mask);
+ }
#if 0
- /* Disable this warning until our user management in packages has improved.
- Currently many packages have to create users in post_install and chown the
- directories. These all resulted in "false-positive" warnings. */
-
- if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
- _alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
- "filesystem: %u:%u package: %u:%u\n"), filename,
- lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: directory ownership differs on %s\n"
- "filesystem: %u:%u package: %u:%u\n", filename,
- lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
- }
+ /* Disable this warning until our user management in packages has improved.
+ Currently many packages have to create users in post_install and chown the
+ directories. These all resulted in "false-positive" warnings. */
+
+ if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
+ _alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
+ "filesystem: %u:%u package: %u:%u\n"), filename,
+ lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: directory ownership differs on %s\n"
+ "filesystem: %u:%u package: %u:%u\n", filename,
+ lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
+ }
#endif
- _alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
- filename);
- archive_read_data_skip(archive);
- return 0;
- } else {
- /* case 5: trying to overwrite dir with file, don't allow it */
- _alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
- filename);
- archive_read_data_skip(archive);
- return 1;
- }
- } else if(S_ISDIR(entrymode)) {
- /* case 4: trying to overwrite file with dir */
- _alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
- filename);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
+ filename);
+ archive_read_data_skip(archive);
+ return 0;
+ } else if(S_ISDIR(lsbuf.st_mode)) {
+ /* case 5: trying to overwrite dir with file, don't allow it */
+ _alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
+ filename);
+ archive_read_data_skip(archive);
+ return 1;
+ } else if(S_ISDIR(entrymode)) {
+ /* case 4: trying to overwrite file with dir */
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
+ filename);
+ } else {
+ /* case 3: trying to overwrite file with file */
+ /* if file is in NoUpgrade, don't touch it */
+ if(_alpm_fnmatch_patterns(handle->noupgrade, entryname) == 0) {
+ notouch = 1;
} else {
- /* case 3: */
- /* if file is in NoUpgrade, don't touch it */
- if(_alpm_fnmatch_patterns(handle->noupgrade, entryname) == 0) {
- notouch = 1;
- } else {
- alpm_backup_t *backup;
- /* go to the backup array and see if our conflict is there */
- /* check newpkg first, so that adding backup files is retroactive */
- backup = _alpm_needbackup(entryname, newpkg);
- if(backup) {
- needbackup = 1;
- }
-
- /* check oldpkg for a backup entry, store the hash if available */
- if(oldpkg) {
- backup = _alpm_needbackup(entryname, oldpkg);
- if(backup) {
- hash_orig = backup->hash;
- needbackup = 1;
- }
- }
+ alpm_backup_t *oldbackup;
+ if(oldpkg && (oldbackup = _alpm_needbackup(entryname, oldpkg))) {
+ hash_orig = oldbackup->hash;
+ needbackup = 1;
+ } else if(backup) {
+ /* allow adding backup files retroactively */
+ needbackup = 1;
}
}
}
- /* we need access to the original entryname later after calls to
- * archive_entry_set_pathname(), so we need to dupe it and free() later */
- STRDUP(entryname_orig, entryname, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ if(notouch || needbackup) {
+ if(filename_len + strlen(".pacnew") >= PATH_MAX) {
+ _alpm_log(handle, ALPM_LOG_ERROR,
+ _("unable to extract %s.pacnew: path too long"), filename);
+ return 1;
+ }
+ strcpy(filename + filename_len, ".pacnew");
+ }
- if(needbackup) {
- char *checkfile;
- char *hash_local = NULL, *hash_pkg = NULL;
- size_t len;
+ if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) {
+ /* if FORCE was used, unlink() each file (whether it's there
+ * or not) before extracting. This prevents the old "Text file busy"
+ * error that crops up if forcing a glibc or pacman upgrade. */
+ unlink(filename);
+ }
+
+ _alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
+ if(perform_extraction(handle, archive, entry, filename)) {
+ errors++;
+ return errors;
+ }
- len = strlen(filename) + 10;
- MALLOC(checkfile, len,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(checkfile, len, "%s.paccheck", filename);
+ if(backup) {
+ FREE(backup->hash);
+ backup->hash = alpm_compute_md5sum(filename);
+ }
- if(perform_extraction(handle, archive, entry, checkfile, entryname_orig)) {
- errors++;
- goto needbackup_cleanup;
- }
+ if(notouch) {
+ alpm_event_pacnew_created_t event = {
+ .type = ALPM_EVENT_PACNEW_CREATED,
+ .from_noupgrade = 1,
+ .oldpkg = oldpkg,
+ .newpkg = newpkg,
+ .file = filename
+ };
+ /* "remove" the .pacnew suffix */
+ filename[filename_len] = '\0';
+ EVENT(handle, &event);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: %s installed as %s.pacnew\n", filename, filename);
+ } else if(needbackup) {
+ char *hash_local = NULL, *hash_pkg = NULL;
+ char origfile[PATH_MAX] = "";
- hash_local = alpm_compute_md5sum(filename);
- hash_pkg = alpm_compute_md5sum(checkfile);
+ strncat(origfile, filename, filename_len);
- /* update the md5 hash in newpkg's backup (it will be the new original) */
- alpm_list_t *i;
- for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) {
- alpm_backup_t *backup = i->data;
- char *newhash;
- if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
- continue;
- }
- STRDUP(newhash, hash_pkg, errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- FREE(backup->hash);
- backup->hash = newhash;
- }
+ hash_local = alpm_compute_md5sum(origfile);
+ hash_pkg = backup ? backup->hash : alpm_compute_md5sum(filename);
- _alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", origfile);
_alpm_log(handle, ALPM_LOG_DEBUG, "current: %s\n", hash_local);
_alpm_log(handle, ALPM_LOG_DEBUG, "new: %s\n", hash_pkg);
_alpm_log(handle, ALPM_LOG_DEBUG, "original: %s\n", hash_orig);
@@ -339,8 +350,8 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
/* local and new files are the same, updating anyway to get
* correct timestamps */
_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
- entryname_orig);
- if(try_rename(handle, checkfile, filename)) {
+ origfile);
+ if(try_rename(handle, filename, origfile)) {
errors++;
}
} else if(hash_orig && hash_pkg && strcmp(hash_orig, hash_pkg) == 0) {
@@ -348,146 +359,38 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
* including any user changes */
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: leaving existing file in place\n");
- unlink(checkfile);
+ unlink(filename);
} else if(hash_orig && hash_local && strcmp(hash_orig, hash_local) == 0) {
/* installed file has NOT been changed by user,
* update to the new version */
_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
- entryname_orig);
- if(try_rename(handle, checkfile, filename)) {
+ origfile);
+ if(try_rename(handle, filename, origfile)) {
errors++;
}
} else {
- /* none of the three files matched another, unpack the new file alongside
- * the local file */
-
- if(oldpkg) {
- char *newpath;
- size_t newlen = strlen(filename) + strlen(".pacnew") + 1;
-
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "action: keeping current file and installing"
- " new one with .pacnew ending\n");
-
- MALLOC(newpath, newlen,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(newpath, newlen, "%s.pacnew", filename);
-
- if(try_rename(handle, checkfile, newpath)) {
- errors++;
- } else {
- alpm_event_pacnew_created_t event = {
- .type = ALPM_EVENT_PACNEW_CREATED,
- .from_noupgrade = 0,
- .oldpkg = oldpkg,
- .newpkg = newpkg,
- .file = filename
- };
- EVENT(handle, &event);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s installed as %s\n", filename, newpath);
- }
-
- free(newpath);
- } else {
- char *newpath;
- size_t newlen = strlen(filename) + strlen(".pacorig") + 1;
-
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "action: saving existing file with a .pacorig ending"
- " and installing a new one\n");
-
- MALLOC(newpath, newlen,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(newpath, newlen, "%s.pacorig", filename);
-
- /* move the existing file to the "pacorig" */
- if(try_rename(handle, filename, newpath)) {
- errors++; /* failed rename filename -> filename.pacorig */
- errors++; /* failed rename checkfile -> filename */
- } else {
- /* rename the file we extracted to the real name */
- if(try_rename(handle, checkfile, filename)) {
- errors++;
- } else {
- alpm_event_pacorig_created_t event = {
- .type = ALPM_EVENT_PACORIG_CREATED,
- .newpkg = newpkg,
- .file = filename
- };
- EVENT(handle, &event);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s saved as %s\n", filename, newpath);
- }
- }
-
- free(newpath);
- }
- }
-
-needbackup_cleanup:
- free(checkfile);
- free(hash_local);
- free(hash_pkg);
- } else {
- size_t len;
- /* we didn't need a backup */
- if(notouch) {
- /* change the path to a .pacnew extension */
- _alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
- /* remember len so we can get the old filename back for the event */
- len = strlen(filename);
- strncat(filename, ".pacnew", PATH_MAX - len);
- } else {
- _alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
- }
-
- if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) {
- /* if FORCE was used, unlink() each file (whether it's there
- * or not) before extracting. This prevents the old "Text file busy"
- * error that crops up if forcing a glibc or pacman upgrade. */
- unlink(filename);
- }
-
- if(perform_extraction(handle, archive, entry, filename, entryname_orig)) {
- /* error */
- free(entryname_orig);
- errors++;
- return errors;
- }
-
- if(notouch) {
+ /* none of the three files matched another, leave the unpacked
+ * file alongside the local file */
alpm_event_pacnew_created_t event = {
.type = ALPM_EVENT_PACNEW_CREATED,
- .from_noupgrade = 1,
+ .from_noupgrade = 0,
.oldpkg = oldpkg,
.newpkg = newpkg,
- .file = filename
+ .file = origfile
};
- /* "remove" the .pacnew suffix */
- filename[len] = '\0';
+ _alpm_log(handle, ALPM_LOG_DEBUG,
+ "action: keeping current file and installing"
+ " new one with .pacnew ending\n");
EVENT(handle, &event);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s installed as %s.pacnew\n", filename, filename);
- /* restore */
- filename[len] = '.';
+ "warning: %s installed as %s\n", origfile, filename);
}
- /* calculate an hash if this is in newpkg's backup */
- alpm_list_t *i;
- for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) {
- alpm_backup_t *backup = i->data;
- char *newhash;
- if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
- continue;
- }
- _alpm_log(handle, ALPM_LOG_DEBUG, "appending backup entry for %s\n", entryname_orig);
- newhash = alpm_compute_md5sum(filename);
- FREE(backup->hash);
- backup->hash = newhash;
+ free(hash_local);
+ if(!backup) {
+ free(hash_pkg);
}
}
- free(entryname_orig);
return errors;
}
diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h
index 711e0e83..6613e509 100644
--- a/lib/libalpm/add.h
+++ b/lib/libalpm/add.h
@@ -1,7 +1,7 @@
/*
* add.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 4a69bf84..21102860 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -1,7 +1,7 @@
/*
* alpm.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index e6ef3ae3..06e080be 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1,7 +1,7 @@
/*
* alpm.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -202,9 +202,6 @@ typedef enum _alpm_siglevel_t {
ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12),
ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13),
- ALPM_SIG_PACKAGE_SET = (1 << 27),
- ALPM_SIG_PACKAGE_TRUST_SET = (1 << 28),
-
ALPM_SIG_USE_DEFAULT = (1 << 31)
} alpm_siglevel_t;
@@ -445,10 +442,7 @@ typedef enum _alpm_event_type_t {
ALPM_EVENT_PACNEW_CREATED,
/** A .pacsave file was created; See alpm_event_pacsave_created_t for
* arguments */
- ALPM_EVENT_PACSAVE_CREATED,
- /** A .pacorig file was created; See alpm_event_pacorig_created_t for
- * arguments */
- ALPM_EVENT_PACORIG_CREATED
+ ALPM_EVENT_PACSAVE_CREATED
} alpm_event_type_t;
typedef struct _alpm_event_any_t {
@@ -539,15 +533,6 @@ typedef struct _alpm_event_pacsave_created_t {
const char *file;
} alpm_event_pacsave_created_t;
-typedef struct _alpm_event_pacorig_created_t {
- /** Type of event. */
- alpm_event_type_t type;
- /** New package. */
- alpm_pkg_t *newpkg;
- /** Filename of the file without the .pacorig suffix. */
- const char *file;
-} alpm_event_pacorig_created_t;
-
/** Events.
* This is an union passed to the callback, that allows the frontend to know
* which type of event was triggered (via type). It is then possible to
@@ -564,7 +549,6 @@ typedef union _alpm_event_t {
alpm_event_pkgdownload_t pkgdownload;
alpm_event_pacnew_created_t pacnew_created;
alpm_event_pacsave_created_t pacsave_created;
- alpm_event_pacorig_created_t pacorig_created;
} alpm_event_t;
/** Event callback. */
@@ -1101,6 +1085,12 @@ int alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg);
*/
const char *alpm_pkg_get_filename(alpm_pkg_t *pkg);
+/** Returns the package base name.
+ * @param pkg a pointer to package
+ * @return a reference to an internal string
+ */
+const char *alpm_pkg_get_base(alpm_pkg_t *pkg);
+
/** Returns the package name.
* @param pkg a pointer to package
* @return a reference to an internal string
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index e881196d..70bd8cf2 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -1,7 +1,7 @@
/*
* alpm_list.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index 65b26bec..5c6d3cad 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -1,7 +1,7 @@
/*
* alpm_list.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c
index aeb41316..5ccec036 100644
--- a/lib/libalpm/backup.c
+++ b/lib/libalpm/backup.c
@@ -1,7 +1,7 @@
/*
* backup.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -47,11 +47,10 @@ int _alpm_split_backup(const char *string, alpm_backup_t **backup)
*ptr = '\0';
ptr++;
/* now str points to the filename and ptr points to the hash */
- STRDUP((*backup)->name, str, return -1);
- STRDUP((*backup)->hash, ptr, return -1);
+ STRDUP((*backup)->name, str, FREE(str); return -1);
+ STRDUP((*backup)->hash, ptr, FREE(str); return -1);
FREE(str);
- return 0;
-}
+ return 0;}
/* Look for a filename in a alpm_pkg_t.backup list. If we find it,
* then we return the full backup entry.
diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h
index 3d9d4e53..03c9872a 100644
--- a/lib/libalpm/backup.h
+++ b/lib/libalpm/backup.h
@@ -1,7 +1,7 @@
/*
* backup.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 7d141c6d..6fd6cd5b 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -1,7 +1,7 @@
/*
* be_local.c : backend for the local database
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -63,6 +63,12 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
* initialized.
*/
+static const char *_cache_get_base(alpm_pkg_t *pkg)
+{
+ LAZY_LOAD(INFRQ_DESC, NULL);
+ return pkg->base;
+}
+
static const char *_cache_get_desc(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
@@ -297,6 +303,7 @@ static int _cache_force_load(alpm_pkg_t *pkg)
* logic.
*/
static struct pkg_operations local_pkg_ops = {
+ .get_base = _cache_get_base,
.get_desc = _cache_get_desc,
.get_url = _cache_get_url,
.get_builddate = _cache_get_builddate,
@@ -701,6 +708,8 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
_alpm_log(db->handle, ALPM_LOG_ERROR, _("%s database is inconsistent: version "
"mismatch on package %s\n"), db->treename, info->name);
}
+ } else if(strcmp(line, "%BASE%") == 0) {
+ READ_AND_STORE(info->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(info->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -801,6 +810,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
alpm_backup_t *backup;
CALLOC(backup, 1, sizeof(alpm_backup_t), goto error);
if(_alpm_split_backup(line, &backup)) {
+ FREE(backup);
goto error;
}
info->backup = alpm_list_add(info->backup, backup);
@@ -904,6 +914,10 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
free(path);
fprintf(fp, "%%NAME%%\n%s\n\n"
"%%VERSION%%\n%s\n\n", info->name, info->version);
+ if(info->base) {
+ fprintf(fp, "%%BASE%%\n"
+ "%s\n\n", info->base);
+ }
if(info->desc) {
fprintf(fp, "%%DESC%%\n"
"%s\n\n", info->desc);
@@ -1022,11 +1036,6 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
cleanup:
umask(oldmask);
-
- if(fp) {
- fclose(fp);
- }
-
return retval;
}
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 5617f4fa..3e27232d 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -1,7 +1,7 @@
/*
* be_package.c : backend for packages
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -193,7 +193,7 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
STRDUP(newpkg->name, ptr, return -1);
newpkg->name_hash = _alpm_hash_sdbm(newpkg->name);
} else if(strcmp(key, "pkgbase") == 0) {
- /* not used atm */
+ STRDUP(newpkg->base, ptr, return -1);
} else if(strcmp(key, "pkgver") == 0) {
STRDUP(newpkg->version, ptr, return -1);
} else if(strcmp(key, "basever") == 0) {
@@ -437,6 +437,7 @@ static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size,
static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, struct archive *archive)
{
int ret = 0;
+ size_t i;
size_t mtree_maxsize = 0;
size_t mtree_cursize = 0;
size_t files_size = 0; /* we clean up the existing array so this is fine */
@@ -448,7 +449,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
"found mtree for package %s, getting file list\n", pkg->filename);
/* throw away any files we might have already found */
- for (size_t i = 0; i < pkg->files.count; i++) {
+ for(i = 0; i < pkg->files.count; i++) {
free(pkg->files.files[i].name);
}
free(pkg->files.files);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 52459483..20130dcd 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -1,7 +1,7 @@
/*
* be_sync.c : backend for sync databases
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -614,6 +614,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(_alpm_validate_filename(db, pkg->name, pkg->filename) < 0) {
return -1;
}
+ } else if(strcmp(line, "%BASE%") == 0) {
+ READ_AND_STORE(pkg->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(pkg->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -707,7 +709,7 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
_alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename);
#ifndef HAVE_LIBGPGME
- if((level &= ~ALPM_SIG_PACKAGE_SET) != 0 && level != ALPM_SIG_USE_DEFAULT) {
+ if(level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
}
#endif
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index db07102c..0af3e3a8 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -1,7 +1,7 @@
/*
* conflict.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -48,15 +48,19 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
{
alpm_conflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_conflict_t), return NULL);
+ CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
conflict->package1_hash = pkg1->name_hash;
conflict->package2_hash = pkg2->name_hash;
- STRDUP(conflict->package1, pkg1->name, return NULL);
- STRDUP(conflict->package2, pkg2->name, return NULL);
+ STRDUP(conflict->package1, pkg1->name, goto error);
+ STRDUP(conflict->package2, pkg2->name, goto error);
conflict->reason = reason;
return conflict;
+
+error:
+ alpm_conflict_free(conflict);
+ return NULL;
}
/**
@@ -79,11 +83,15 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
newconflict->package1_hash = conflict->package1_hash;
newconflict->package2_hash = conflict->package2_hash;
- STRDUP(newconflict->package1, conflict->package1, return NULL);
- STRDUP(newconflict->package2, conflict->package2, return NULL);
+ STRDUP(newconflict->package1, conflict->package1, goto error);
+ STRDUP(newconflict->package2, conflict->package2, goto error);
newconflict->reason = conflict->reason;
return newconflict;
+
+error:
+ alpm_conflict_free(newconflict);
+ return NULL;
}
/**
@@ -265,7 +273,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
{
alpm_fileconflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
+ CALLOC(conflict, 1, sizeof(alpm_fileconflict_t), goto error);
STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error);
@@ -284,6 +292,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
return conflicts;
error:
+ alpm_fileconflict_free(conflict);
RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
}
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index 886e9279..a5daad10 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -1,7 +1,7 @@
/*
* conflict.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 26e351fd..fe208be0 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -1,7 +1,7 @@
/*
* db.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -331,7 +331,7 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local)
alpm_db_t *db;
CALLOC(db, 1, sizeof(alpm_db_t), return NULL);
- STRDUP(db->treename, treename, return NULL);
+ STRDUP(db->treename, treename, FREE(db); return NULL);
if(is_local) {
db->status |= DB_STATUS_LOCAL;
} else {
@@ -542,7 +542,10 @@ alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
}
if(!(db->status & DB_STATUS_PKGCACHE)) {
- load_pkgcache(db);
+ if(load_pkgcache(db)) {
+ /* handle->error set in local/sync-db-populate */
+ return NULL;
+ }
}
return db->pkgcache;
@@ -562,13 +565,15 @@ alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db)
/* "duplicate" pkg then add it to pkgcache */
int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
{
- alpm_pkg_t *newpkg;
+ alpm_pkg_t *newpkg = NULL;
if(db == NULL || pkg == NULL || !(db->status & DB_STATUS_PKGCACHE)) {
return -1;
}
if(_alpm_pkg_dup(pkg, &newpkg)) {
+ /* we return memory on "non-fatal" error in _alpm_pkg_dup */
+ _alpm_pkg_free(newpkg);
return -1;
}
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 3025be9a..b19cb3f8 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -1,7 +1,7 @@
/*
* db.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index baa02b75..a43269d0 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -1,7 +1,7 @@
/*
* delta.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -306,10 +306,10 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
/* start at index 1 -- match 0 is the entire match */
len = pmatch[1].rm_eo - pmatch[1].rm_so;
- STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, return NULL);
+ STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, goto error);
len = pmatch[2].rm_eo - pmatch[2].rm_so;
- STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, return NULL);
+ STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, goto error);
len = pmatch[3].rm_eo - pmatch[3].rm_so;
if(len < sizeof(filesize)) {
@@ -319,12 +319,16 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
}
len = pmatch[4].rm_eo - pmatch[4].rm_so;
- STRNDUP(delta->from, &line[pmatch[4].rm_so], len, return NULL);
+ STRNDUP(delta->from, &line[pmatch[4].rm_so], len, goto error);
len = pmatch[5].rm_eo - pmatch[5].rm_so;
- STRNDUP(delta->to, &line[pmatch[5].rm_so], len, return NULL);
+ STRNDUP(delta->to, &line[pmatch[5].rm_so], len, goto error);
return delta;
+
+error:
+ _alpm_delta_free(delta);
+ return NULL;
}
#undef NUM_MATCHES
@@ -342,14 +346,18 @@ alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta)
{
alpm_delta_t *newdelta;
CALLOC(newdelta, 1, sizeof(alpm_delta_t), return NULL);
- STRDUP(newdelta->delta, delta->delta, return NULL);
- STRDUP(newdelta->delta_md5, delta->delta_md5, return NULL);
- STRDUP(newdelta->from, delta->from, return NULL);
- STRDUP(newdelta->to, delta->to, return NULL);
+ STRDUP(newdelta->delta, delta->delta, goto error);
+ STRDUP(newdelta->delta_md5, delta->delta_md5, goto error);
+ STRDUP(newdelta->from, delta->from, goto error);
+ STRDUP(newdelta->to, delta->to, goto error);
newdelta->delta_size = delta->delta_size;
newdelta->download_size = delta->download_size;
return newdelta;
+
+error:
+ _alpm_delta_free(newdelta);
+ return NULL;
}
/* vim: set noet: */
diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h
index c57e6c50..d52f73b8 100644
--- a/lib/libalpm/delta.h
+++ b/lib/libalpm/delta.h
@@ -1,7 +1,7 @@
/*
* delta.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index f2ee8f41..daab9c3f 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -1,7 +1,7 @@
/*
* deps.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -48,13 +48,17 @@ static alpm_depmissing_t *depmiss_new(const char *target, alpm_depend_t *dep,
{
alpm_depmissing_t *miss;
- MALLOC(miss, sizeof(alpm_depmissing_t), return NULL);
+ CALLOC(miss, 1, sizeof(alpm_depmissing_t), return NULL);
- STRDUP(miss->target, target, return NULL);
+ STRDUP(miss->target, target, goto error);
miss->depend = _alpm_dep_dup(dep);
- STRDUP(miss->causingpkg, causingpkg, return NULL);
+ STRDUP(miss->causingpkg, causingpkg, goto error);
return miss;
+
+error:
+ alpm_depmissing_free(miss);
+ return NULL;
}
void SYMEXPORT alpm_depmissing_free(alpm_depmissing_t *miss)
@@ -465,11 +469,11 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
return NULL;
}
- MALLOC(depend, sizeof(alpm_depend_t), return NULL);
+ CALLOC(depend, 1, sizeof(alpm_depend_t), return NULL);
/* Note the extra space in ": " to avoid matching the epoch */
if((desc = strstr(depstring, ": ")) != NULL) {
- STRDUP(depend->desc, desc + 2, return NULL);
+ STRDUP(depend->desc, desc + 2, goto error);
deplen = desc - depstring;
} else {
/* no description- point desc at NULL at end of string for later use */
@@ -509,13 +513,17 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
}
/* copy the right parts to the right places */
- STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
+ STRNDUP(depend->name, depstring, ptr - depstring, goto error);
depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) {
- STRNDUP(depend->version, version, desc - version, return NULL);
+ STRNDUP(depend->version, version, desc - version, goto error);
}
return depend;
+
+error:
+ alpm_dep_free(depend);
+ return NULL;
}
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
@@ -523,13 +531,17 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
alpm_depend_t *newdep;
CALLOC(newdep, 1, sizeof(alpm_depend_t), return NULL);
- STRDUP(newdep->name, dep->name, return NULL);
- STRDUP(newdep->version, dep->version, return NULL);
- STRDUP(newdep->desc, dep->desc, return NULL);
+ STRDUP(newdep->name, dep->name, goto error);
+ STRDUP(newdep->version, dep->version, goto error);
+ STRDUP(newdep->desc, dep->desc, goto error);
newdep->name_hash = dep->name_hash;
newdep->mod = dep->mod;
return newdep;
+
+error:
+ alpm_dep_free(newdep);
+ return NULL;
}
/* These parameters are messy. We check if this package, given a list of
@@ -597,11 +609,13 @@ int _alpm_recursedeps(alpm_db_t *db, alpm_list_t **targs, int include_explicit)
alpm_pkg_t *deppkg = j->data;
if(_alpm_pkg_depends_on(pkg, deppkg)
&& can_remove_package(db, deppkg, *targs, include_explicit)) {
- alpm_pkg_t *copy;
+ alpm_pkg_t *copy = NULL;
_alpm_log(db->handle, ALPM_LOG_DEBUG, "adding '%s' to the targets\n",
deppkg->name);
/* add it to the target list */
if(_alpm_pkg_dup(deppkg, &copy)) {
+ /* we return memory on "non-fatal" error in _alpm_pkg_dup */
+ _alpm_pkg_free(copy);
return -1;
}
*targs = alpm_list_add(*targs, copy);
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index bd717bbd..06504497 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -1,7 +1,7 @@
/*
* deps.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index af87f755..3b496c2e 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -1,7 +1,7 @@
/*
* diskspace.c
*
- * Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -112,7 +112,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((mnt = getmntent(fp))) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(mp->mount_dir, mnt->mnt_dir, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(mp->mount_dir, mnt->mnt_dir, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -135,7 +135,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((ret = getmntent(fp, &mnt)) == 0) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(mp->mount_dir, mnt->mnt_mountp, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(mp->mount_dir, mnt->mnt_mountp, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -162,7 +162,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
for(; entries-- > 0; fsp++) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(mp->mount_dir, fsp->f_mntonname, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(mp->mount_dir, fsp->f_mntonname, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
#if defined(HAVE_GETMNTINFO_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FLAG)
diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h
index c9fab9b4..2f5116d0 100644
--- a/lib/libalpm/diskspace.h
+++ b/lib/libalpm/diskspace.h
@@ -1,7 +1,7 @@
/*
* diskspace.h
*
- * Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index e3409f99..63523aa3 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -1,7 +1,7 @@
/*
* download.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -379,7 +379,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
payload->tempfile_name = randpath;
free(payload->remote_name);
STRDUP(payload->remote_name, strrchr(randpath, '/') + 1,
- RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL));
+ fclose(fp); RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL));
return fp;
}
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 512a376b..b1e8b079 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -1,7 +1,7 @@
/*
* dload.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index fb6b8564..76b710cb 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -1,7 +1,7 @@
/*
* error.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c
index c41989ca..b1d01927 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -1,7 +1,7 @@
/*
* filelist.c
*
- * Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/filelist.h b/lib/libalpm/filelist.h
index f948cfb5..580e8a91 100644
--- a/lib/libalpm/filelist.h
+++ b/lib/libalpm/filelist.h
@@ -1,7 +1,7 @@
/*
* filelist.h
*
- * Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2012-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/graph.c b/lib/libalpm/graph.c
index 725b7045..4d58169c 100644
--- a/lib/libalpm/graph.c
+++ b/lib/libalpm/graph.c
@@ -1,7 +1,7 @@
/*
* graph.c - helpful graph structure and setup/teardown methods
*
- * Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h
index 401260b2..fb24d730 100644
--- a/lib/libalpm/graph.h
+++ b/lib/libalpm/graph.h
@@ -1,7 +1,7 @@
/*
* graph.h - helpful graph structure and setup/teardown methods
*
- * Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2007-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c
index aa51a63c..9c7de903 100644
--- a/lib/libalpm/group.c
+++ b/lib/libalpm/group.c
@@ -1,7 +1,7 @@
/*
* group.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/group.h b/lib/libalpm/group.h
index fb28457c..97ea878c 100644
--- a/lib/libalpm/group.h
+++ b/lib/libalpm/group.h
@@ -1,7 +1,7 @@
/*
* group.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index fa999489..4915d0bf 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -1,7 +1,7 @@
/*
* handle.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 2888f0f3..58931395 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -1,7 +1,7 @@
/*
* handle.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/libarchive-compat.h b/lib/libalpm/libarchive-compat.h
index 7c126416..610c7cd9 100644
--- a/lib/libalpm/libarchive-compat.h
+++ b/lib/libalpm/libarchive-compat.h
@@ -4,7 +4,7 @@
/*
* libarchive-compat.h
*
- * Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2013-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 9af5e846..8ee61df5 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -1,7 +1,7 @@
/*
* log.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/log.h b/lib/libalpm/log.h
index 41f98b20..6365eff3 100644
--- a/lib/libalpm/log.h
+++ b/lib/libalpm/log.h
@@ -1,7 +1,7 @@
/*
* log.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index d9ed3d31..4b5120b0 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
@@ -83,6 +83,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
* backend logic that needs lazy access, such as the local database through
* a lazy-load cache. However, the defaults will work just fine for fully-
* populated package structures. */
+static const char *_pkg_get_base(alpm_pkg_t *pkg) { return pkg->base; }
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
@@ -144,6 +145,7 @@ static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; }
* struct itself with no abstraction layer or any type of lazy loading.
*/
struct pkg_operations default_pkg_ops = {
+ .get_base = _pkg_get_base,
.get_desc = _pkg_get_desc,
.get_url = _pkg_get_url,
.get_builddate = _pkg_get_builddate,
@@ -186,6 +188,13 @@ const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
return pkg->filename;
}
+const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
+{
+ ASSERT(pkg != NULL, return NULL);
+ pkg->handle->pm_errno = 0;
+ return pkg->ops->get_base(pkg);
+}
+
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
@@ -566,6 +575,7 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
newpkg->name_hash = pkg->name_hash;
STRDUP(newpkg->filename, pkg->filename, goto cleanup);
+ STRDUP(newpkg->base, pkg->base, goto cleanup);
STRDUP(newpkg->name, pkg->name, goto cleanup);
STRDUP(newpkg->version, pkg->version, goto cleanup);
STRDUP(newpkg->desc, pkg->desc, goto cleanup);
@@ -641,6 +651,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
}
FREE(pkg->filename);
+ FREE(pkg->base);
FREE(pkg->name);
FREE(pkg->version);
FREE(pkg->desc);
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 357c20ef..4a32f611 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -1,7 +1,7 @@
/*
* package.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -43,6 +43,7 @@
* defined default_pkg_ops struct to work just fine for their needs.
*/
struct pkg_operations {
+ const char *(*get_base) (alpm_pkg_t *);
const char *(*get_desc) (alpm_pkg_t *);
const char *(*get_url) (alpm_pkg_t *);
alpm_time_t (*get_builddate) (alpm_pkg_t *);
@@ -85,6 +86,7 @@ extern struct pkg_operations default_pkg_ops;
struct __alpm_pkg_t {
unsigned long name_hash;
char *filename;
+ char *base;
char *name;
char *version;
char *desc;
diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c
index a740233d..989a8c1b 100644
--- a/lib/libalpm/pkghash.c
+++ b/lib/libalpm/pkghash.c
@@ -1,7 +1,7 @@
/*
* pkghash.c
*
- * Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/pkghash.h b/lib/libalpm/pkghash.h
index f2887c3d..9184f9e4 100644
--- a/lib/libalpm/pkghash.h
+++ b/lib/libalpm/pkghash.h
@@ -1,7 +1,7 @@
/*
* pkghash.h
*
- * Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2011-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index f9b24ef1..ccf64dc5 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -1,7 +1,7 @@
/*
* remove.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h
index 123720ab..a9392e2e 100644
--- a/lib/libalpm/remove.h
+++ b/lib/libalpm/remove.h
@@ -1,7 +1,7 @@
/*
* remove.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 8391315a..b1c1ee98 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -1,7 +1,7 @@
/*
* signing.c
*
- * Copyright (c) 2008-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/signing.h b/lib/libalpm/signing.h
index b414b1f1..e5137d7b 100644
--- a/lib/libalpm/signing.h
+++ b/lib/libalpm/signing.h
@@ -1,7 +1,7 @@
/*
* signing.h
*
- * Copyright (c) 2008-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2008-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index c513b6b5..79192cff 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -1,7 +1,7 @@
/*
* sync.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -736,11 +736,11 @@ static int apply_deltas(alpm_handle_t *handle)
} else {
/* len = cachedir len + from len + '/' + null */
len = strlen(cachedir) + strlen(d->from) + 2;
- MALLOC(from, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1));
+ MALLOC(from, len, free(delta); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(from, len, "%s/%s", cachedir, d->from);
}
len = strlen(cachedir) + strlen(d->to) + 2;
- MALLOC(to, len, free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
+ MALLOC(to, len, free(delta); free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(to, len, "%s/%s", cachedir, d->to);
/* build the patch command */
@@ -862,7 +862,7 @@ static struct dload_payload *build_payload(alpm_handle_t *handle,
struct dload_payload *payload;
CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
- STRDUP(payload->remote_name, filename, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ STRDUP(payload->remote_name, filename, FREE(payload); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
payload->max_size = size;
payload->servers = servers;
return payload;
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index c15d348f..6281550f 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -1,7 +1,7 @@
/*
* sync.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index e1caa5e3..6a26e753 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -1,7 +1,7 @@
/*
* trans.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -347,7 +347,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath,
/* either extract or copy the scriptlet */
len += strlen("/.INSTALL");
- MALLOC(scriptfn, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ MALLOC(scriptfn, len, free(tmpdir); RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(scriptfn, len, "%s/.INSTALL", tmpdir);
if(is_archive) {
if(_alpm_unpack_single(handle, filepath, tmpdir, ".INSTALL")) {
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index d2bbcf80..fa9886d0 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -1,7 +1,7 @@
/*
* trans.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 1e367369..4d851327 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -1,7 +1,7 @@
/*
* util.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -542,7 +542,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
while(dup2(pipefd[1], 2) == -1 && errno == EINTR);
close(pipefd[0]);
close(pipefd[1]);
- close(cwdfd);
+ if(cwdfd >= 0) {
+ close(cwdfd);
+ }
/* use fprintf instead of _alpm_log to send output through the parent */
if(chroot(handle->root) != 0) {
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 6f47073b..4839618a 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -1,7 +1,7 @@
/*
* util.h
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
diff --git a/lib/libalpm/version.c b/lib/libalpm/version.c
index 6d68aacd..c7a57e45 100644
--- a/lib/libalpm/version.c
+++ b/lib/libalpm/version.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by