diff options
author | Dan McGee <dan@archlinux.org> | 2008-12-03 05:15:02 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-12-03 05:15:02 +0100 |
commit | 61c6552862345cb155903cd1566f1cef5c527a94 (patch) | |
tree | a9c85c46a4ccd5cd8c001689541706e9287e4c50 /lib | |
parent | 9394f229a0328228e810b7d4588b24643b42df6a (diff) | |
parent | a1f7c83dbf3bce492163362d2896e3a4176be616 (diff) | |
download | pacman-61c6552862345cb155903cd1566f1cef5c527a94.tar.gz pacman-61c6552862345cb155903cd1566f1cef5c527a94.tar.xz |
Merge branch 'maint'
Conflicts:
lib/libalpm/dload.c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/be_files.c | 11 | ||||
-rw-r--r-- | lib/libalpm/delta.c | 15 | ||||
-rw-r--r-- | lib/libalpm/dload.c | 10 |
3 files changed, 26 insertions, 10 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index f5d4e826..b9ff6464 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -51,7 +51,7 @@ * Return the last update time as number of seconds from the epoch. * Returns 0 if the value is unknown or can't be read. */ -time_t getlastupdate(const pmdb_t *db) +static time_t getlastupdate(const pmdb_t *db) { FILE *fp; char *file; @@ -85,7 +85,7 @@ time_t getlastupdate(const pmdb_t *db) /* * writes the dbpath/.lastupdate file with the value in time */ -int setlastupdate(const pmdb_t *db, time_t time) +static int setlastupdate(const pmdb_t *db, time_t time) { FILE *fp; char *file; @@ -500,7 +500,7 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(fgets(line, 512, fp) == NULL) { goto error; } - info->reason = atol(_alpm_strtrim(line)); + info->reason = (pmpkgreason_t)atol(_alpm_strtrim(line)); } else if(strcmp(line, "%SIZE%") == 0 || strcmp(line, "%CSIZE%") == 0) { /* NOTE: the CSIZE and SIZE fields both share the "size" field * in the pkginfo_t struct. This can be done b/c CSIZE @@ -618,7 +618,10 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) _alpm_strtrim(line); if(strcmp(line, "%DELTAS%") == 0) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { - info->deltas = alpm_list_add(info->deltas, _alpm_delta_parse(line)); + pmdelta_t *delta = _alpm_delta_parse(line); + if(delta) { + info->deltas = alpm_list_add(info->deltas, delta); + } } } } diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index 22d9beb4..8dce7e3b 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -22,6 +22,8 @@ #include <stdlib.h> #include <string.h> #include <limits.h> +#include <sys/types.h> +#include <regex.h> /* libalpm */ #include "delta.h" @@ -257,6 +259,19 @@ pmdelta_t *_alpm_delta_parse(char *line) { pmdelta_t *delta; char *tmp = line, *tmp2; + regex_t reg; + + regcomp(®, + "^[^[:space:]]* [[:xdigit:]]{32}" + " [^[:space:]]* [[:xdigit:]]{32}" + " [^[:space:]]* [[:xdigit:]]{32} [[:digit:]]*$", + REG_EXTENDED | REG_NOSUB | REG_NEWLINE); + if(regexec(®, line, 0, 0, 0) != 0) { + /* delta line is invalid, return NULL */ + regfree(®); + return(NULL); + } + regfree(®); CALLOC(delta, 1, sizeof(pmdelta_t), RET_ERR(PM_ERR_MEMORY, NULL)); diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index f197d060..9934f30a 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -112,12 +112,12 @@ static int download_internal(const char *url, const char *localpath, FILE *dlf, *localf = NULL; struct url_stat ust; struct stat st; - int chk_resume = 0; - size_t dl_thisfile = 0; + int chk_resume = 0, ret = 0; + size_t dl_thisfile = 0, nread = 0; char *tempfile, *destfile, *filename; - int ret = 0; struct sigaction new_action, old_action; struct url *fileurl = url_for_string(url); + char buffer[PM_DLBUF_LEN]; if(!fileurl) { return(-1); @@ -208,9 +208,8 @@ static int download_internal(const char *url, const char *localpath, handle->dlcb(filename, 0, ust.size); } - size_t nread = 0; - char buffer[PM_DLBUF_LEN]; while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { + size_t nwritten = 0; if(ferror(dlf)) { pm_errno = PM_ERR_LIBFETCH; _alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"), @@ -219,7 +218,6 @@ static int download_internal(const char *url, const char *localpath, goto cleanup; } - size_t nwritten = 0; while(nwritten < nread) { nwritten += fwrite(buffer, 1, (nread - nwritten), localf); if(ferror(localf)) { |