diff options
author | Dan McGee <dan@archlinux.org> | 2011-07-29 18:49:38 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-02 08:20:34 -0400 |
commit | cbaff216b3eca57b4fd717da53f43a6713722e95 (patch) | |
tree | 1ef21cb061959410a827c3123ca0e7a28f7610a6 /lib/libalpm/be_sync.c | |
parent | 573260556db49c62f5cf751f53812b7e06c1decb (diff) | |
download | pacman-cbaff216b3eca57b4fd717da53f43a6713722e95.tar.xz |
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_sync.c')
-rw-r--r-- | lib/libalpm/be_sync.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 07356f0a..d4c71a8e 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -443,7 +443,8 @@ static int sync_db_populate(alpm_db_t *db) #define READ_NEXT() do { \ if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \ - line = _alpm_strtrim(buf.line); \ + line = buf.line; \ + _alpm_strip_newline(line); \ } while(0) #define READ_AND_STORE(f) do { \ @@ -453,9 +454,9 @@ static int sync_db_populate(alpm_db_t *db) #define READ_AND_STORE_ALL(f) do { \ char *linedup; \ - READ_NEXT(); \ - if(strlen(line) == 0) break; \ - STRDUP(linedup, line, goto error); \ + if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \ + if(_alpm_strip_newline(buf.line) == 0) break; \ + STRDUP(linedup, buf.line, goto error); \ f = alpm_list_add(f, linedup); \ } while(1) /* note the while(1) and not (0) */ @@ -493,7 +494,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive, || strcmp(filename, "deltas") == 0) { int ret; while((ret = _alpm_archive_fgets(archive, &buf)) == ARCHIVE_OK) { - char *line = _alpm_strtrim(buf.line); + char *line = buf.line; + _alpm_strip_newline(line); if(strcmp(line, "%NAME%") == 0) { READ_NEXT(); |