[dovecot-cvs] dovecot/src/login auth-connection.c,1.13,1.14 client-authenticate.c,1.21,1.22 client.c,1.18,1.19 master.c,1.6,1.7 ssl-proxy-gnutls.c,1.1,1.2 ssl-proxy-openssl.c,1.6,1.7
cras at procontrol.fi
cras at procontrol.fi
Wed Dec 18 17:15:44 EET 2002
- Previous message: [dovecot-cvs] dovecot/src/master auth-process.c,1.18,1.19 imap-process.c,1.15,1.16 login-process.c,1.20,1.21 main.c,1.18,1.19 settings.c,1.30,1.31 ssl-init.c,1.4,1.5
- Next message: [dovecot-cvs] dovecot/src/lib buffer.c,1.1,1.2 buffer.h,1.2,1.3 compat.c,1.6,1.7 compat.h,1.14,1.15 data-stack.c,1.10,1.11 hex-binary.c,1.3,1.4 ioloop-poll.c,1.4,1.5 istream-file.c,1.2,1.3 istream.c,1.1,1.2 md5.c,1.5,1.6 mempool-alloconly.c,1.9,1.10 Message-Id: <20021218151544.050E5238CA@danu.procontrol.fi>
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/login
In directory danu:/tmp/cvs-serv3676/src/login
Modified Files:
auth-connection.c client-authenticate.c client.c master.c
ssl-proxy-gnutls.c ssl-proxy-openssl.c
Log Message:
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
cleanups and a couple of minor bugfixes.
Index: auth-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/auth-connection.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- auth-connection.c 6 Dec 2002 01:09:23 -0000 1.13
+++ auth-connection.c 18 Dec 2002 15:15:42 -0000 1.14
@@ -119,7 +119,8 @@
hash_foreach(conn->requests, request_hash_destroy, NULL);
hash_destroy(conn->requests);
- (void)close(conn->fd);
+ if (close(conn->fd) < 0)
+ i_error("close(imap-auth) failed: %m");
io_remove(conn->io);
i_stream_unref(conn->input);
o_stream_unref(conn->output);
Index: client-authenticate.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/client-authenticate.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- client-authenticate.c 18 Dec 2002 10:40:43 -0000 1.21
+++ client-authenticate.c 18 Dec 2002 15:15:42 -0000 1.22
@@ -251,8 +251,6 @@
return;
}
- t_push();
-
linelen = strlen(line);
buf = buffer_create_static_hard(data_stack_pool, linelen);
@@ -272,8 +270,6 @@
bufsize = buffer_get_used_size(buf);
safe_memset(buffer_free_without_data(buf), 0, bufsize);
-
- t_pop();
}
int cmd_authenticate(Client *client, const char *method_name)
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/client.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- client.c 18 Dec 2002 10:40:43 -0000 1.18
+++ client.c 18 Dec 2002 15:15:42 -0000 1.19
@@ -27,13 +27,14 @@
static void client_set_title(Client *client)
{
- char host[MAX_IP_LEN];
+ const char *host;
if (!verbose_proctitle || !process_per_connection)
return;
- if (net_ip2host(&client->ip, host) < 0)
- strcpy(host, "??");
+ host = net_ip2host(&client->ip);
+ if (host == NULL)
+ host = "??";
process_title_set(t_strdup_printf(client->tls ? "[%s TLS]" : "[%s]",
host));
@@ -133,36 +134,39 @@
}
}
-static char *get_next_arg(char **line)
+static char *get_next_arg(char **linep)
{
- char *start;
+ char *line, *start;
int quoted;
- while (**line == ' ') (*line)++;
+ line = *linep;
+ while (*line == ' ') line++;
- if (**line == '"') {
+ /* @UNSAFE: get next argument, unescape arg if it's quoted */
+ if (*line == '"') {
quoted = TRUE;
- (*line)++;
+ line++;
- start = *line;
- while (**line != '\0' && **line != '"') {
- if (**line == '\\' && (*line)[1] != '\0')
- (*line)++;
- (*line)++;
+ start = line;
+ while (*line != '\0' && *line != '"') {
+ if (*line == '\\' && line[1] != '\0')
+ line++;
+ line++;
}
- if (**line == '"')
- *(*line)++ = '\0';
+ if (*line == '"')
+ *line++ = '\0';
string_remove_escapes(start);
} else {
- start = *line;
- while (**line != '\0' && **line != ' ')
- (*line)++;
+ start = line;
+ while (*line != '\0' && *line != ' ')
+ line++;
- if (**line == ' ')
- *(*line)++ = '\0';
+ if (*line == ' ')
+ *line++ = '\0';
}
+ *linep = line;
return start;
}
@@ -237,16 +241,17 @@
void *context)
{
Client *client = key;
- Client **destroy_clients = context;
- int i;
+ Buffer *destroy_buf = context;
+ Client *const *destroy_clients;
+ size_t i, count;
- for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
- if (destroy_clients[i] == NULL ||
- destroy_clients[i]->created > client->created) {
- memmove(destroy_clients+i+1, destroy_clients+i,
- sizeof(Client *) *
- (CLIENT_DESTROY_OLDEST_COUNT - i-1));
- destroy_clients[i] = client;
+ destroy_clients = buffer_get_data(destroy_buf, &count);
+ count /= sizeof(Client *);
+
+ for (i = 0; i < count; i++) {
+ if (destroy_clients[i]->created > client->created) {
+ buffer_insert(destroy_buf, i * sizeof(Client *),
+ &client, sizeof(client));
break;
}
}
@@ -254,13 +259,21 @@
static void client_destroy_oldest(void)
{
- Client *destroy_clients[CLIENT_DESTROY_OLDEST_COUNT];
- int i;
+ Buffer *destroy_buf;
+ Client *const *destroy_clients;
+ size_t i, count;
- memset(destroy_clients, 0, sizeof(destroy_clients));
- hash_foreach(clients, client_hash_destroy_oldest, destroy_clients);
+ /* find the oldest clients and put them to destroy-buffer */
+ destroy_buf = buffer_create_static_hard(data_stack_pool,
+ sizeof(Client *) *
+ CLIENT_DESTROY_OLDEST_COUNT);
+ hash_foreach(clients, client_hash_destroy_oldest, destroy_buf);
- for (i = 0; i < CLIENT_DESTROY_OLDEST_COUNT; i++) {
+ /* then kill them */
+ destroy_clients = buffer_get_data(destroy_buf, &count);
+ count /= sizeof(Client *);
+
+ for (i = 0; i < count; i++) {
client_destroy(destroy_clients[i],
"Disconnected: Connection queue full");
}
@@ -357,10 +370,11 @@
void client_syslog(Client *client, const char *text)
{
- char host[MAX_IP_LEN];
+ const char *host;
- if (net_ip2host(&client->ip, host) == -1)
- host[0] = '\0';
+ host = net_ip2host(&client->ip);
+ if (host == NULL)
+ host = "??";
syslog(LOG_INFO, "%s [%s]", text, host);
}
Index: master.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/master.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- master.c 20 Nov 2002 20:01:26 -0000 1.6
+++ master.c 18 Dec 2002 15:15:42 -0000 1.7
@@ -111,7 +111,8 @@
clients_destroy_all();
- (void)close(LOGIN_MASTER_SOCKET_FD);
+ if (close(LOGIN_MASTER_SOCKET_FD) < 0)
+ i_fatal("close(master) failed: %m");
io_remove(io_master);
io_master = NULL;
Index: ssl-proxy-gnutls.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/ssl-proxy-gnutls.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ssl-proxy-gnutls.c 20 Nov 2002 14:05:13 -0000 1.1
+++ ssl-proxy-gnutls.c 18 Dec 2002 15:15:42 -0000 1.2
@@ -448,17 +448,11 @@
static void gcrypt_log_handler(void *context __attr_unused__, int level,
const char *fmt, va_list args)
{
- char *buf;
-
- t_push();
-
- buf = t_malloc(printf_string_upper_bound(fmt, args));
- vsprintf(buf, fmt, args);
-
- if (level == GCRY_LOG_FATAL)
- i_error("gcrypt fatal: %s", buf);
-
- t_pop();
+ if (level == GCRY_LOG_FATAL) {
+ t_push();
+ i_error("gcrypt fatal: %s", t_strdup_vprintf(fmt, args));
+ t_pop();
+ }
}
void ssl_proxy_init(void)
Index: ssl-proxy-openssl.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/ssl-proxy-openssl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ssl-proxy-openssl.c 1 Dec 2002 16:15:28 -0000 1.6
+++ ssl-proxy-openssl.c 18 Dec 2002 15:15:42 -0000 1.7
@@ -135,14 +135,15 @@
{
unsigned long err;
char *buf;
+ size_t err_size = 256;
err = ERR_get_error();
if (err == 0)
return strerror(errno);
- buf = t_malloc(256);
- buf[255] = '\0';
- ERR_error_string_n(err, buf, 255);
+ buf = t_malloc(err_size);
+ buf[err_size-1] = '\0';
+ ERR_error_string_n(err, buf, err_size-1);
return buf;
}
- Previous message: [dovecot-cvs] dovecot/src/master auth-process.c,1.18,1.19 imap-process.c,1.15,1.16 login-process.c,1.20,1.21 main.c,1.18,1.19 settings.c,1.30,1.31 ssl-init.c,1.4,1.5
- Next message: [dovecot-cvs] dovecot/src/lib buffer.c,1.1,1.2 buffer.h,1.2,1.3 compat.c,1.6,1.7 compat.h,1.14,1.15 data-stack.c,1.10,1.11 hex-binary.c,1.3,1.4 ioloop-poll.c,1.4,1.5 istream-file.c,1.2,1.3 istream.c,1.1,1.2 md5.c,1.5,1.6 mempool-alloconly.c,1.9,1.10 Message-Id: <20021218151544.050E5238CA@danu.procontrol.fi>
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list