dovecot-2.2: Avoid using PATH_MAX.

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 17:55:53 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/75aadea5c2a2
changeset: 15284:75aadea5c2a2
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 28 15:07:11 2012 +0300
description:
Avoid using PATH_MAX.

diffstat:

 src/lib-master/master-instance.c                 |   2 +-
 src/lib-storage/index/dbox-common/dbox-storage.c |  12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diffs (46 lines):

diff -r 88a05f387743 -r 75aadea5c2a2 src/lib-master/master-instance.c
--- a/src/lib-master/master-instance.c	Thu Sep 27 02:55:14 2012 +0300
+++ b/src/lib-master/master-instance.c	Fri Sep 28 15:07:11 2012 +0300
@@ -110,7 +110,7 @@
 		i_error("open(%s) failed: %m", list->path);
 		return -1;
 	}
-	input = i_stream_create_fd(fd, PATH_MAX, TRUE);
+	input = i_stream_create_fd(fd, (size_t)-1, TRUE);
 	while ((line = i_stream_read_next_line(input)) != NULL) T_BEGIN {
 		if (master_instance_list_add_line(list, line) < 0)
 			i_error("Invalid line in %s: %s", list->path, line);
diff -r 88a05f387743 -r 75aadea5c2a2 src/lib-storage/index/dbox-common/dbox-storage.c
--- a/src/lib-storage/index/dbox-common/dbox-storage.c	Thu Sep 27 02:55:14 2012 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-storage.c	Fri Sep 28 15:07:11 2012 +0300
@@ -31,25 +31,23 @@
 dbox_alt_path_has_changed(const char *root_dir,
 			  const char *alt_path, const char *alt_symlink_path)
 {
-	char buf[PATH_MAX];
+	const char *linkpath;
 	ssize_t ret;
 
-	ret = readlink(alt_symlink_path, buf, sizeof(buf)-1);
-	if (ret < 0) {
+	if (t_readlink(alt_symlink_path, &linkpath) < 0) {
 		if (errno == ENOENT)
 			return alt_path != NULL;
 		i_error("readlink(%s) failed: %m", alt_symlink_path);
 		return FALSE;
 	}
-	buf[ret] = '\0';
 
 	if (alt_path == NULL) {
 		i_warning("dbox %s: Original ALT=%s, "
-			  "but currently no ALT path set", root_dir, buf);
+			  "but currently no ALT path set", root_dir, linkpath);
 		return TRUE;
-	} else if (strcmp(buf, alt_path) != 0) {
+	} else if (strcmp(linkpath, alt_path) != 0) {
 		i_warning("dbox %s: Original ALT=%s, "
-			  "but currently ALT=%s", root_dir, buf, alt_path);
+			  "but currently ALT=%s", root_dir, linkpath, alt_path);
 		return TRUE;
 	}
 	return FALSE;


More information about the dovecot-cvs mailing list