[pacman-dev] (no subject)
For now, I'm just sending in the malloc patch (which, of course, now only frees variables that exist in the original source, not ones invented for the previous patches). To quickly recap an irc conversation with agregory, it looks like implementing checks before overwriting the db is more complicated if doing it properly (that is, downloading the newdb to a tempfile, rather than moving the olddb out of the way and then moving it back if need be). The downloader curl_download_internal (via _alpm_download) seems to expect a directory argument, rather than a filename (it appends the remote filename to the local path). I'll definitely try the checks patch again, though probably not in the next couple of days. Ivy
From: Ivy Foster <ivy.foster@gmail.com> Signed-off-by: Ivy Foster <ivy.foster@gmail.com> --- lib/libalpm/be_sync.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 32a669d..06f9619 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -231,8 +231,13 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db) /* print server + filename into a buffer */ len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2; - /* TODO fix leak syncpath and umask unset */ - MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + MALLOC(payload.fileurl, len, + { + free(syncpath); + umask(oldmask); + RET_ERR(handle, ALPM_ERR_MEMORY, -1); + } + ); snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext); payload.handle = handle; payload.force = force; @@ -271,8 +276,13 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db) len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6; } - /* TODO fix leak syncpath and umask unset */ - MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + MALLOC(payload.fileurl, len, + { + free(syncpath); + umask(oldmask); + RET_ERR(handle, ALPM_ERR_MEMORY, -1); + } + ); if(final_db_url != NULL) { snprintf(payload.fileurl, len, "%s.sig", final_db_url); -- 2.9.3
participants (1)
-
ivy.foster@gmail.com