dovecot-2.2-pigeonhole: lib-sieve: util: Fixed bug in t_realpath...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Thu Apr 23 00:04:48 UTC 2015
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/dd430dfa2ddb
changeset: 2039:dd430dfa2ddb
user: Stephan Bosch <stephan at rename-it.nl>
date: Thu Apr 23 02:04:38 2015 +0200
description:
lib-sieve: util: Fixed bug in t_realpath() normalization occuring with relative symlinks below root.
Also contains a few small code cleanups.
diffstat:
src/lib-sieve/util/realpath.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diffs (60 lines):
diff -r 6926e54e8817 -r dd430dfa2ddb src/lib-sieve/util/realpath.c
--- a/src/lib-sieve/util/realpath.c Wed Apr 22 21:43:33 2015 +0200
+++ b/src/lib-sieve/util/realpath.c Thu Apr 23 02:04:38 2015 +0200
@@ -42,13 +42,13 @@
const char *p;
size_t asize;
- if (path[0] != '/') {
+ if (path[0] != '/') {
/* relative; initialize npath with current directory */
if (t_getcwd_alloc(&npath, &asize) < 0)
return -1;
npath_pos = npath + strlen(npath);
i_assert(npath[0] == '/');
- } else {
+ } else {
/* absolute; initialize npath with root */
asize = 128;
npath = t_buffer_get(asize);
@@ -77,9 +77,9 @@
} else if (seglen == 2 && p[0] == '.' && p[1] == '.') {
/* a reference to parent segment; back up to previous slash */
if (npath_pos > npath + 1) {
- if (*npath_pos == '/')
+ if (*(npath_pos-1) == '/')
npath_pos--;
- for (; *npath_pos != '/'; npath_pos--);
+ for (; *(npath_pos-1) != '/'; npath_pos--);
}
} else {
/* make sure npath now ends in slash */
@@ -95,7 +95,7 @@
}
/* copy segment to normalized path */
- (void)memmove(npath_pos, p, segend - p);
+ (void)memmove(npath_pos, p, seglen);
npath_pos += seglen;
}
@@ -175,16 +175,16 @@
/* use as new source path */
path = segend = npath_link;
-
+
if (path[0] == '/') {
/* absolute symlink; start over at root */
npath_pos = npath + 1;
} else {
/* relative symlink; back up to previous segment */
if (npath_pos > npath + 1) {
- if (*npath_pos == '/')
+ if (*(npath_pos-1) == '/')
npath_pos--;
- for (; *npath_pos != '/'; npath_pos--);
+ for (; *(npath_pos-1) != '/'; npath_pos--);
}
}
More information about the dovecot-cvs
mailing list