From 4b384b7f0b0e840e09e3bffd2dbb59b88bdd4864 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 29 Feb 2012 16:33:21 -0600 Subject: Fix a memory leak when loading an invalid package This is easily triggered via a `pacman -Sc` operation when it attempts to open a delta file as a package- we end up leaking loads of memory due to us never freeing the archive object. When you have upwards of 1200 delta files in your sync database directory, this results in a memory leak of nearly 1.5 MiB. Also fix another memory leak noticed at the same time- we need to call the internal _alpm_pkg_free() function, as without the origin data being set the public free function will do nothing. Signed-off-by: Dan McGee --- lib/libalpm/be_package.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 4d9d0e82..ad34640a 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -382,7 +382,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, /* try to create an archive object to read in the package */ if((archive = archive_read_new()) == NULL) { - alpm_pkg_free(newpkg); + _alpm_pkg_free(newpkg); RET_ERR(handle, ALPM_ERR_LIBARCHIVE, NULL); } @@ -391,8 +391,8 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, if(archive_read_open_filename(archive, pkgfile, ALPM_BUFFER_SIZE) != ARCHIVE_OK) { - alpm_pkg_free(newpkg); - RET_ERR(handle, ALPM_ERR_PKG_OPEN, NULL); + handle->pm_errno = ALPM_ERR_PKG_OPEN; + goto error; } _alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s\n", pkgfile); -- cgit v1.2.3-24-g4f1b From 986e99a613605985f64f0e3e4c2635717931f77d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 29 Feb 2012 16:47:39 -0600 Subject: Fix a potential memory leak in filelist creation If we begin to create a file list when loading a package, but abort because of an error to one of our goto labels, the memory used to create the file list will leak. This is because we use a set of local variables to hold the data, and thus _alpm_pkg_free() cannot clean up for us. Use the file list struct on the package object as much as possible to keep state when building the file list, thus allowing _alpm_pkg_free() to clean up any partially built data. Signed-off-by: Dan McGee --- lib/libalpm/be_package.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index ad34640a..93b762a1 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -360,8 +360,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, struct archive_entry *entry; alpm_pkg_t *newpkg = NULL; struct stat st; - size_t files_count = 0, files_size = 0; - alpm_file_t *files = NULL; + size_t files_size = 0; if(pkgfile == NULL || strlen(pkgfile) == 0) { RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL); @@ -426,28 +425,34 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, /* for now, ignore all files starting with '.' that haven't * already been handled (for future possibilities) */ } else if(full) { + const size_t files_count = newpkg->files.count; + alpm_file_t *current_file; /* Keep track of all files for filelist generation */ if(files_count >= files_size) { size_t old_size = files_size; + alpm_file_t *newfiles; if(files_size == 0) { files_size = 4; } else { files_size *= 2; } - files = realloc(files, sizeof(alpm_file_t) * files_size); - if(!files) { + newfiles = realloc(newpkg->files.files, + sizeof(alpm_file_t) * files_size); + if(!newfiles) { ALLOC_FAIL(sizeof(alpm_file_t) * files_size); goto error; } /* ensure all new memory is zeroed out, in both the initial * allocation and later reallocs */ - memset(files + old_size, 0, + memset(newfiles + old_size, 0, sizeof(alpm_file_t) * (files_size - old_size)); + newpkg->files.files = newfiles; } - STRDUP(files[files_count].name, entry_name, goto error); - files[files_count].size = archive_entry_size(entry); - files[files_count].mode = archive_entry_mode(entry); - files_count++; + current_file = newpkg->files.files + files_count; + STRDUP(current_file->name, entry_name, goto error); + current_file->size = archive_entry_size(entry); + current_file->mode = archive_entry_mode(entry); + newpkg->files.count++; } if(archive_read_data_skip(archive)) { @@ -485,15 +490,16 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, newpkg->infolevel = INFRQ_BASE | INFRQ_DESC | INFRQ_SCRIPTLET; if(full) { - if(files) { + if(newpkg->files.files) { /* attempt to hand back any memory we don't need */ - files = realloc(files, sizeof(alpm_file_t) * files_count); + newpkg->files.files = realloc(newpkg->files.files, + sizeof(alpm_file_t) * newpkg->files.count); /* "checking for conflicts" requires a sorted list, ensure that here */ _alpm_log(handle, ALPM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile); - newpkg->files.files = files_msort(files, files_count); + newpkg->files.files = files_msort(newpkg->files.files, + newpkg->files.count); } - newpkg->files.count = files_count; newpkg->infolevel |= INFRQ_FILES; } -- cgit v1.2.3-24-g4f1b From 4ffa0401d22347332d663f1d400e182d5a181ea2 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 23 Feb 2012 10:35:38 -0600 Subject: Translation updates from Transifex * it updates to all translations * minor fr, pt_BR, de, lt, sk and uk updates * add new strings in pacman translation catalog Signed-off-by: Dan McGee --- lib/libalpm/po/it.po | 76 +++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/po/it.po b/lib/libalpm/po/it.po index 329b1cf0..b3d0c06c 100644 --- a/lib/libalpm/po/it.po +++ b/lib/libalpm/po/it.po @@ -4,16 +4,16 @@ # # Translators: # Dan McGee , 2011. -# Giovanni Scafora , 2011. +# Giovanni Scafora , 2011, 2012. msgid "" msgstr "" "Project-Id-Version: Arch Linux Pacman package manager\n" "Report-Msgid-Bugs-To: http://bugs.archlinux.org/index.php?project=3\n" -"POT-Creation-Date: 2011-11-13 21:47-0600\n" -"PO-Revision-Date: 2011-10-06 15:43+0000\n" -"Last-Translator: giovanni \n" +"POT-Creation-Date: 2012-02-23 10:28-0600\n" +"PO-Revision-Date: 2012-02-16 15:25+0000\n" +"Last-Translator: Giovanni Scafora \n" "Language-Team: Italian (http://www.transifex.net/projects/p/archlinux-pacman/" -"team/it/)\n" +"language/it/)\n" "Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -22,11 +22,11 @@ msgstr "" #, c-format msgid "%s-%s is up to date -- skipping\n" -msgstr "%s-%s è aggiornato, sarà ignorato\n" +msgstr "%s-%s è aggiornato e sarà ignorato\n" #, c-format msgid "%s-%s is up to date -- reinstalling\n" -msgstr "%s-%s è aggiornato, sarà reinstallato\n" +msgstr "%s-%s è aggiornato ma sarà reinstallato\n" #, c-format msgid "downgrading package %s (%s => %s)\n" @@ -52,7 +52,7 @@ msgstr "" #, c-format msgid "extract: not overwriting dir with file %s\n" -msgstr "estrazione: non posso sovrascrivere la directory con il file %s\n" +msgstr "estrazione: impossibile sovrascrivere la directory con il file %s\n" #, c-format msgid "extract: symlink %s does not point to dir\n" @@ -72,7 +72,7 @@ msgstr "impossibile installare %s come %s (%s)\n" #, c-format msgid "%s installed as %s\n" -msgstr "%s installato come %s\n" +msgstr "%s è stato installato come %s\n" #, c-format msgid "extracting %s as %s.pacnew\n" @@ -92,11 +92,11 @@ msgstr "impossibile ripristinare la directory di lavoro (%s)\n" #, c-format msgid "problem occurred while upgrading %s\n" -msgstr "si sono verificati degli errori durante l'aggiornamento di %s\n" +msgstr "si è verificato un errore durante l'aggiornamento di %s\n" #, c-format msgid "problem occurred while installing %s\n" -msgstr "si sono verificati degli errori durante l'installazione di %s\n" +msgstr "si è verificato un errore durante l'installazione di %s\n" #, c-format msgid "could not update database entry %s-%s\n" @@ -104,11 +104,11 @@ msgstr "impossibile aggiornare la voce %s-%s nel database\n" #, c-format msgid "could not add entry '%s' in cache\n" -msgstr "impossible includere la voce '%s' nella cache\n" +msgstr "impossible aggiungere la voce '%s' nella cache\n" #, c-format msgid "removing invalid database: %s\n" -msgstr "rimozione del database: %s\n" +msgstr "rimozione del database non valido: %s\n" #, c-format msgid "invalid name for database entry '%s'\n" @@ -129,13 +129,13 @@ msgstr "impossibile aprire il file %s: %s\n" #, c-format msgid "%s database is inconsistent: name mismatch on package %s\n" msgstr "" -"il database %s è inconsistente: il nome del pacchetto %s non corrisponde\n" +"il database %s è inconsistente: il nome non corrisponde con il pacchetto %s\n" #, c-format msgid "%s database is inconsistent: version mismatch on package %s\n" msgstr "" -"il database %s è inconsistente: la versione del pacchetto %s non " -"corrisponde\n" +"il database %s è inconsistente: la versione non corrisponde con il pacchetto " +"%s\n" #, c-format msgid "could not create directory %s: %s\n" @@ -143,7 +143,7 @@ msgstr "impossibile creare la directory %s: %s\n" #, c-format msgid "could not parse package description file in %s\n" -msgstr "impossibile analizzare il file di descrizione del pacchetto in %s\n" +msgstr "impossibile analizzare il file della descrizione del pacchetto in %s\n" #, c-format msgid "missing package name in %s\n" @@ -171,7 +171,9 @@ msgstr "impossibile rimuovere il file di lock %s\n" #, c-format msgid "could not parse package description file '%s' from db '%s'\n" -msgstr "impossibile analizzare il file di descrizione '%s' del database '%s'\n" +msgstr "" +"impossibile analizzare il file della descrizione del pacchetto '%s' dal " +"database '%s'\n" #, c-format msgid "database path is undefined\n" @@ -179,7 +181,7 @@ msgstr "il percorso del database non è stato definito\n" #, c-format msgid "dependency cycle detected:\n" -msgstr "individuato un possibile ciclo di dipendenze:\n" +msgstr "è stato individuato un ciclo di dipendenza:\n" #, c-format msgid "%s will be removed after its %s dependency\n" @@ -191,7 +193,7 @@ msgstr "%s sarà installato prima della sua dipendenza %s\n" #, c-format msgid "ignoring package %s-%s\n" -msgstr "sto ignorando il pacchetto %s-%s\n" +msgstr "il pacchetto %s-%s è stato ignorato\n" #, c-format msgid "cannot resolve \"%s\", a dependency of \"%s\"\n" @@ -204,7 +206,7 @@ msgstr "impossibile ottenere le informazioni relative al filesystem\n" #, c-format msgid "could not get filesystem information for %s: %s\n" msgstr "" -"impossibile ottenere le informazione relative al filesystem per %s: %s\n" +"impossibile ottenere le informazione relative al filesystem di %s: %s\n" #, c-format msgid "could not determine mount point for file %s\n" @@ -212,11 +214,11 @@ msgstr "impossibile determinare il punto di montaggio del file %s\n" #, c-format msgid "could not determine filesystem mount points\n" -msgstr "impossibile determinare i mount point del filesystem\n" +msgstr "impossibile determinare i punti di montaggio del filesystem\n" #, c-format msgid "could not determine root mount point %s\n" -msgstr "impossibile determinare il mount point di root %s\n" +msgstr "impossibile determinare il punto di montaggio della root %s\n" #, c-format msgid "Partition %s is mounted read only\n" @@ -233,11 +235,11 @@ msgstr "disco" #, c-format msgid "failed to create temporary file for download\n" -msgstr "impossibile creare la directory temporanea\n" +msgstr "impossibile creare la directory temporanea per il download\n" #, c-format msgid "url '%s' is invalid\n" -msgstr "l'url '%s' non è esatto\n" +msgstr "l'url '%s' non è valido\n" #, c-format msgid "failed retrieving file '%s' from %s : %s\n" @@ -249,7 +251,7 @@ msgstr "%s sembra essere incompleto: %jd/%jd byte\n" #, c-format msgid "failed to download %s\n" -msgstr "impossibile scaricare %s\n" +msgstr "non è stato possibile scaricare %s\n" #, c-format msgid "out of memory!" @@ -329,11 +331,11 @@ msgstr "impossibile aggiornare il database" #, c-format msgid "could not remove database entry" -msgstr "impossibile rimuovere la voce dal database" +msgstr "impossibile rimuovere la voce del database" #, c-format msgid "invalid url for server" -msgstr "url non valido per il server" +msgstr "non è un url valido per il server" #, c-format msgid "no servers configured for repository" @@ -381,7 +383,7 @@ msgstr "il pacchetto non è valido oppure è corrotto" #, c-format msgid "invalid or corrupted package (checksum)" -msgstr "il pacchetto non è valido oppure è corrotto (controllo integrità)" +msgstr "il pacchetto non è valido oppure è corrotto (verifica dell'integrità)" #, c-format msgid "invalid or corrupted package (PGP signature)" @@ -409,11 +411,11 @@ msgstr "impossibile trovare un repository contenente questo pacchetto" #, c-format msgid "missing PGP signature" -msgstr "firma PGP mancante" +msgstr "manca la firma PGP" #, c-format msgid "invalid PGP signature" -msgstr "firma PGP non valida" +msgstr "la firma PGP non è valida" #, c-format msgid "invalid or corrupted delta" @@ -485,7 +487,7 @@ msgstr "impossibile rimuovere %s (%s)\n" #, c-format msgid "could not remove database entry %s-%s\n" -msgstr "impossibile rimuovere la voce %s-%s dal database\n" +msgstr "impossibile rimuovere la voce %s-%s del database\n" #, c-format msgid "could not remove entry '%s' from cache\n" @@ -501,7 +503,7 @@ msgstr "%s: il downgrade del pacchetto è stato ignorato (%s => %s)\n" #, c-format msgid "%s: downgrading from version %s to version %s\n" -msgstr "%s: downgrade in corso dalla versione %s alla versione %s\n" +msgstr "%s: è in corso il downgrade dalla versione %s alla versione %s\n" #, c-format msgid "%s: local (%s) is newer than %s (%s)\n" @@ -510,7 +512,7 @@ msgstr "" #, c-format msgid "ignoring package replacement (%s-%s => %s-%s)\n" -msgstr "sto ignorando la sostituzione del pacchetto (%s-%s => %s-%s)\n" +msgstr "la sostituzione del pacchetto (%s-%s => %s-%s) è stata ignorata\n" #, c-format msgid "cannot replace %s by %s\n" @@ -518,7 +520,7 @@ msgstr "impossibile sostituire %s con %s\n" #, c-format msgid "unresolvable package conflicts detected\n" -msgstr "sono stati rilevati dei conflitti irrisolvibili\n" +msgstr "sono stati rilevati dei conflitti irrisolvibili tra i pacchetti\n" #, c-format msgid "removing '%s' from target list because it conflicts with '%s'\n" @@ -571,7 +573,7 @@ msgstr "impossibile chiamare execv (%s)\n" #, c-format msgid "call to waitpid failed (%s)\n" -msgstr "chiamata a waitpid non riuscita (%s)\n" +msgstr "la chiamata a waitpid non è riuscita (%s)\n" #, c-format msgid "could not open pipe (%s)\n" @@ -588,5 +590,5 @@ msgstr "la cache di %s non esiste, creazione in corso...\n" #, c-format msgid "couldn't find or create package cache, using %s instead\n" msgstr "" -"impossibile trovare o creare la cache del pacchetto, al suo posto sto usando " +"impossibile trovare o creare la cache del pacchetto, al suo posto sarà usato " "%s\n" -- cgit v1.2.3-24-g4f1b