From eaae558bf13ba86abb1c79838e145853858aa2f4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 29 Apr 2005 16:50:04 +0000 Subject: [PATCH] * Significantly reduced the memory footprint of struct CitContext. --- citadel/ChangeLog | 4 ++++ citadel/citserver.c | 4 +--- citadel/room_ops.c | 8 +++++--- citadel/serv_smtp.c | 2 +- citadel/server.h | 11 +++++------ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index f7a4799ac..7e430d813 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 645.14 2005/04/29 16:50:03 ajc + * Significantly reduced the memory footprint of struct CitContext. + Revision 645.13 2005/04/29 16:26:00 ajc * Removed the CtdlRedirectOutput() API, as we are no longer using it. (Oh happy day; no more temp files!) @@ -6637,3 +6640,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citserver.c b/citadel/citserver.c index 67b240380..1c944f172 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -193,7 +193,6 @@ void RemoveContext (struct CitContext *con) lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid); logout(con); - unlink(con->temp); lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid); /* If the client is still connected, blow 'em away. */ @@ -761,13 +760,12 @@ void begin_session(struct CitContext *con) strcpy(con->lastcmdname, " "); strcpy(con->cs_clientname, "(unknown)"); strcpy(con->curr_user, NLI); - strcpy(con->net_node,""); + strcpy(con->net_node, ""); strcpy(con->fake_username, ""); strcpy(con->fake_postname, ""); strcpy(con->fake_hostname, ""); strcpy(con->fake_roomname, ""); generate_nonce(con); - safestrncpy(con->temp, tmpnam(NULL), sizeof con->temp); safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host); safestrncpy(con->cs_addr, "", sizeof con->cs_addr); con->cs_host[sizeof con->cs_host - 1] = 0; diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 47ae34128..cc6111b69 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -1032,8 +1032,10 @@ void cmd_rdir(void) char comment[256]; FILE *ls, *fd; struct stat statbuf; + char tempfilename[PATH_MAX]; if (CtdlAccessCheck(ac_logged_in)) return; + tmpnam(tempfilename); getroom(&CC->room, CC->room.QRname); getuser(&CC->user, CC->curr_user); @@ -1052,7 +1054,7 @@ void cmd_rdir(void) LISTING_FOLLOWS, config.c_fqdn, CTDLDIR, CC->room.QRdirname); snprintf(buf, sizeof buf, "ls %s/files/%s >%s 2> /dev/null", - CTDLDIR, CC->room.QRdirname, CC->temp); + CTDLDIR, CC->room.QRdirname, tempfilename); system(buf); snprintf(buf, sizeof buf, "%s/files/%s/filedir", CTDLDIR, CC->room.QRdirname); @@ -1060,7 +1062,7 @@ void cmd_rdir(void) if (fd == NULL) fd = fopen("/dev/null", "r"); - ls = fopen(CC->temp, "r"); + ls = fopen(tempfilename, "r"); while (fgets(flnm, sizeof flnm, ls) != NULL) { flnm[strlen(flnm) - 1] = 0; if (strcasecmp(flnm, "filedir")) { @@ -1083,7 +1085,7 @@ void cmd_rdir(void) } fclose(ls); fclose(fd); - unlink(CC->temp); + unlink(tempfilename); cprintf("000\n"); } diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 6c46264e9..2990b340a 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -537,7 +537,7 @@ void smtp_mail(char *argbuf) { * to be the user's Internet e-mail address as Citadel knows it. */ if (CC->logged_in) { - strcpy(SMTP->from, CC->cs_inet_email); + safestrncpy(SMTP->from, CC->cs_inet_email, sizeof SMTP->from); cprintf("250 2.1.0 Sender ok <%s>\r\n", SMTP->from); SMTP->message_originated_locally = 1; return; diff --git a/citadel/server.h b/citadel/server.h index 8dbedcf7b..c6d6bb9bc 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -54,12 +54,11 @@ struct CitContext { char curr_user[USERNAME_SIZE]; /* name of current user */ int logged_in; /* logged in */ int internal_pgm; /* authenticated as internal program */ - char temp[PATH_MAX]; /* temp file name */ int nologin; /* not allowed to log in */ int is_local_socket; /* set to 1 if client is on unix domain sock */ int curr_view; /* The view type for the current user/room */ - char net_node[PATH_MAX];/* Is the client another Citadel server? */ + char net_node[32] ;/* Is the client another Citadel server? */ time_t previous_login; /* Date/time of previous login */ char lastcmdname[5]; /* name of last command executed */ unsigned cs_flags; /* miscellaneous flags */ @@ -78,14 +77,14 @@ struct CitContext { char cs_addr[64]; /* address logged in from */ /* The Internet type of thing */ - char cs_inet_email[SIZ];/* Return address of outbound Internet mail */ + char cs_inet_email[128];/* Return address of outbound Internet mail */ FILE *download_fp; /* Fields relating to file transfer */ char download_desired_section[128]; FILE *upload_fp; - char upl_file[PATH_MAX]; + char upl_file[256]; char upl_path[PATH_MAX]; - char upl_comment[SIZ]; + char upl_comment[256]; char upl_filedir[PATH_MAX]; char dl_is_net; char upload_type; @@ -120,7 +119,7 @@ struct CitContext { char fake_hostname[64]; /* Fake hostname */ char fake_roomname[ROOMNAMELEN]; /* Fake roomname */ - char preferred_formats[SIZ]; /* Preferred MIME formats */ + char preferred_formats[256]; /* Preferred MIME formats */ /* Dynamically allocated session data */ struct citimap *IMAP; -- 2.39.2