summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-28 09:56:36 +0200
committerDan McGee <dan@archlinux.org>2011-09-28 11:48:33 +0200
commitf66f9f11cd010a05efe28d0607abbf29ff8dffa5 (patch)
tree9feef88c5394fd36ca71070a71c2efcf57151165 /lib/libalpm/sync.c
parentea3c47825ea6a8cfd0e0d63fd7da0120fcacabc8 (diff)
downloadpacman-f66f9f11cd010a05efe28d0607abbf29ff8dffa5.tar.gz
pacman-f66f9f11cd010a05efe28d0607abbf29ff8dffa5.tar.xz
Fix memory leak in download payload->remote_name
In the sync code, we explicitly allocated a string for this field, while in the dload code itself it was filled in with a pointer to another string. This led to a memory leak in the sync download case. Make remote_name non-const and always explicitly allocate it. This patch ensures this as well as uses malloc + snprintf (rather than calloc) in several codepaths, and eliminates the only use of PATH_MAX in the download code. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index b1da6829..fd48ef37 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -872,7 +872,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
/* print server + filename into a buffer */
len = strlen(server_url) + strlen(payload->remote_name) + 2;
- CALLOC(payload->fileurl, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name);
payload->handle = handle;
payload->allow_resume = 1;