Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_local.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-07-29 18:49:38 -0500
committerDan McGee <dan@archlinux.org>2011-08-02 08:20:34 -0400
commitcbaff216b3eca57b4fd717da53f43a6713722e95 (patch)
tree1ef21cb061959410a827c3123ca0e7a28f7610a6 /lib/libalpm/be_local.c
parent573260556db49c62f5cf751f53812b7e06c1decb (diff)
Don't trim whitespace when reading database entries
We don't write with extra or unknown whitespace, so there is little reason for us to trim it when reading either. This also fixes the hopefully never encountered "paths that start or end with spaces" issue, for which two pactests have been added. The tests also contain other evil characters that we have encountered before and handle just fine, but it doesn't hurt to ensure we don't break such support in the future. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_local.c')
-rw-r--r--lib/libalpm/be_local.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 261ad871..49661e24 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -500,7 +500,7 @@ static char *get_pkgpath(alpm_db_t *db, alpm_pkg_t *info)
#define READ_NEXT() do { \
if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) goto error; \
- _alpm_strtrim(line); \
+ _alpm_strip_newline(line); \
} while(0)
#define READ_AND_STORE(f) do { \
@@ -510,8 +510,8 @@ static char *get_pkgpath(alpm_db_t *db, alpm_pkg_t *info)
#define READ_AND_STORE_ALL(f) do { \
char *linedup; \
- READ_NEXT(); \
- if(strlen(line) == 0) break; \
+ if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) goto error; \
+ if(_alpm_strip_newline(line) == 0) break; \
STRDUP(linedup, line, goto error); \
f = alpm_list_add(f, linedup); \
} while(1) /* note the while(1) and not (0) */
@@ -629,12 +629,12 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
goto error;
}
while(fgets(line, sizeof(line), fp)) {
- _alpm_strtrim(line);
+ _alpm_strip_newline(line);
if(strcmp(line, "%FILES%") == 0) {
size_t files_count = 0, files_size = 0;
alpm_file_t *files = NULL;
- while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
+ while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line)) {
if(files_count >= files_size) {
size_t old_size = files_size;
if(files_size == 0) {
@@ -661,7 +661,7 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
info->files.count = files_count;
info->files.files = files;
} else if(strcmp(line, "%BACKUP%") == 0) {
- while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) {
+ while(fgets(line, sizeof(line), fp) && _alpm_strip_newline(line)) {
alpm_backup_t *backup;
CALLOC(backup, 1, sizeof(alpm_backup_t), goto error);
if(_alpm_split_backup(line, &backup)) {