* Significantly reduced the memory footprint of struct CitContext.
authorArt Cancro <ajc@citadel.org>
Fri, 29 Apr 2005 16:50:04 +0000 (16:50 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 29 Apr 2005 16:50:04 +0000 (16:50 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/room_ops.c
citadel/serv_smtp.c
citadel/server.h

index f7a4799acd9dc912df0ddd038b6b9aabb89bad95..7e430d81367d0377994a5f3a53f6f5aaa481989f 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 67b2403805d8e7ee78ca27c96a8ff174e01ac01e..1c944f172db5e901653d9d2469af2bf933ad99fa 100644 (file)
@@ -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;
index 47ae341289b7b03a87eb88df28dede85b4b849db..cc6111b695a5674f3e69bac8aebeb3bc58092061 100644 (file)
@@ -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");
 }
index 6c46264e9c8c6b1065b591a93cee2e02a7cfbbf1..2990b340a418e65c9c8b1c61dfa2bc1ae1b8a38e 100644 (file)
@@ -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;
index 8dbedcf7bbe189f3cd7344139be35f2e61350dc4..c6d6bb9bc13f5afbfe165e5958b5e0c44b7ca44e 100644 (file)
@@ -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 <bc> */
        char fake_roomname[ROOMNAMELEN];        /* Fake roomname <bc> */
 
-       char preferred_formats[SIZ];            /* Preferred MIME formats */
+       char preferred_formats[256];            /* Preferred MIME formats */
 
        /* Dynamically allocated session data */
        struct citimap *IMAP;