[dovecot-cvs] dovecot/src/master auth-process.c,1.19,1.20 imap-process.c,1.16,1.17 login-process.c,1.21,1.22 main.c,1.19,1.20
cras at procontrol.fi
cras at procontrol.fi
Thu Dec 19 03:02:38 EET 2002
Update of /home/cvs/dovecot/src/master
In directory danu:/tmp/cvs-serv11467/master
Modified Files:
auth-process.c imap-process.c login-process.c main.c
Log Message:
Buffer related cleanups. Use PATH_MAX instead of hardcoded 1024 for paths.
Added str_path() and str_ppath() functions. i_snprintf() now returns only -1
or 0 depending on if buffer got full. dec2str() returns the string allocated
from data stack. Instead of just casting to (long) or (int), we now use
dec2str() with printf-like functions. Added o_stream_send_str(). Added
strocpy() and replaced all strcpy()s and strncpy()s with it.
Pretty much untested, hope it doesn't break too badly :)
Index: auth-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/auth-process.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- auth-process.c 18 Dec 2002 15:15:42 -0000 1.19
+++ auth-process.c 19 Dec 2002 01:02:36 -0000 1.20
@@ -66,15 +66,15 @@
req = process->requests;
if (req == NULL) {
- i_warning("imap-auth %ld sent us unrequested reply for id %d",
- (long)process->pid, reply->id);
+ i_warning("imap-auth %s sent us unrequested reply for id %d",
+ dec2str(process->pid), reply->id);
return;
}
if (reply->id != req->id) {
- i_fatal("imap-auth %ld sent invalid id for reply "
+ i_fatal("imap-auth %s sent invalid id for reply "
"(got %d, expecting %d)",
- (long)process->pid, reply->id, req->id);
+ dec2str(process->pid), reply->id, req->id);
}
/* auth process isn't trusted, validate all data to make sure
@@ -215,8 +215,8 @@
/* set correct permissions */
if (chown(path, set_login_uid, set_login_gid) < 0) {
- i_fatal("login: chown(%s, %d, %d) failed: %m",
- path, (int)set_login_uid, (int)set_login_gid);
+ i_fatal("login: chown(%s, %s, %s) failed: %m",
+ path, dec2str(set_login_uid), dec2str(set_login_gid));
}
/* move master communication handle to 0 */
@@ -252,7 +252,7 @@
config->chroot);
/* set other environment */
- env_put(t_strdup_printf("AUTH_PROCESS=%d", (int) getpid()));
+ env_put(t_strconcat("AUTH_PROCESS=", dec2str(getpid()), NULL));
env_put(t_strconcat("METHODS=", config->methods, NULL));
env_put(t_strconcat("REALMS=", config->realms, NULL));
env_put(t_strconcat("USERINFO=", config->userinfo, NULL));
Index: imap-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/imap-process.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- imap-process.c 18 Dec 2002 15:15:42 -0000 1.16
+++ imap-process.c 19 Dec 2002 01:02:36 -0000 1.17
@@ -28,15 +28,15 @@
if (uid < (uid_t)set_first_valid_uid ||
(set_last_valid_uid != 0 && uid > (uid_t)set_last_valid_uid)) {
- i_error("imap process isn't allowed to use UID %ld",
- (long) uid);
+ i_error("imap process isn't allowed to use UID %s",
+ dec2str(uid));
return FALSE;
}
if (gid < (gid_t)set_first_valid_gid ||
(set_last_valid_gid != 0 && gid > (gid_t)set_last_valid_gid)) {
i_error("imap process isn't allowed to use "
- "GID %ld (UID is %ld)", (long) gid, (long) uid);
+ "GID %s (UID is %s)", dec2str(gid), dec2str(uid));
return FALSE;
}
@@ -135,8 +135,6 @@
/* master */
imap_process_count++;
PID_ADD_PROCESS_TYPE(pid, PROCESS_TYPE_IMAP);
- if (close(socket) < 0)
- i_error("close(imap client) failed: %m");
return MASTER_RESULT_SUCCESS;
}
Index: login-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/login-process.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- login-process.c 18 Dec 2002 15:15:42 -0000 1.21
+++ login-process.c 19 Dec 2002 01:02:36 -0000 1.22
@@ -153,7 +153,9 @@
authreq->auth_id = ++auth_id_counter;
authreq->fd = client_fd;
memcpy(&authreq->ip, &req.ip, sizeof(IPADDR));
- strcpy(authreq->login_tag, req.login_tag);
+ if (strocpy(authreq->login_tag, req.login_tag,
+ sizeof(authreq->login_tag)) < 0)
+ i_panic("login_tag overflow");
auth_process = auth_process_find(req.auth_process);
if (auth_process == NULL) {
Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/main.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- main.c 18 Dec 2002 15:15:42 -0000 1.19
+++ main.c 19 Dec 2002 01:02:36 -0000 1.20
@@ -127,14 +127,15 @@
msg = get_exit_status_message(status);
if (msg != NULL)
msg = t_strconcat(" (", msg, ")", NULL);
- i_error("child %d (%s) returned error %d%s",
- (int)pid, process_type_name,
+ i_error("child %s (%s) returned error %d%s",
+ dec2str(pid), process_type_name,
status, msg);
}
} else if (WIFSIGNALED(status)) {
login_process_abormal_exit(pid);
- i_error("child %d (%s) killed with signal %d",
- (int)pid, process_type_name, WTERMSIG(status));
+ i_error("child %s (%s) killed with signal %d",
+ dec2str(pid), process_type_name,
+ WTERMSIG(status));
}
}
More information about the dovecot-cvs
mailing list