dovecot-2.0: t_askpass(): Removed a limit of 1024 bytes for the ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 30 02:17:44 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/6ea1671108f1
changeset: 12481:6ea1671108f1
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 30 00:12:54 2010 +0000
description:
t_askpass(): Removed a limit of 1024 bytes for the password.
diffstat:
src/lib/askpass.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diffs (59 lines):
diff -r 77d582b2dc51 -r 6ea1671108f1 src/lib/askpass.c
--- a/src/lib/askpass.c Mon Nov 29 23:58:19 2010 +0000
+++ b/src/lib/askpass.c Tue Nov 30 00:12:54 2010 +0000
@@ -1,6 +1,8 @@
/* Copyright (c) 2006-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
+#include "buffer.h"
+#include "str.h"
#include "askpass.h"
#include <stdio.h>
@@ -8,7 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
-void askpass(const char *prompt, char *buf, size_t buf_size)
+static void askpass_str(const char *prompt, buffer_t *pass)
{
struct termios old_tio, tio;
bool restore_tio = FALSE;
@@ -37,13 +39,10 @@
/* read the password */
pos = 0;
while (read(fd, &ch, 1) > 0) {
- if (pos >= buf_size-1)
- break;
if (ch == '\n' || ch == '\r')
break;
- buf[pos++] = ch;
+ buffer_append_c(pass, ch);
}
- buf[pos] = '\0';
if (restore_tio)
(void)tcsetattr(fd, TCSAFLUSH, &old_tio);
@@ -52,10 +51,19 @@
(void)close(fd);
}
+void askpass(const char *prompt, char *buf, size_t buf_size)
+{
+ buffer_t str;
+
+ buffer_create_data(&str, buf, buf_size);
+ askpass_str(prompt, &str);
+ buffer_append_c(&str, '\0');
+}
+
const char *t_askpass(const char *prompt)
{
- char buf[1024];
+ string_t *str = t_str_new(32);
- askpass(prompt, buf, sizeof(buf));
- return t_strdup(buf);
+ askpass_str(prompt, str);
+ return str_c(str);
}
More information about the dovecot-cvs
mailing list