[cyrus-imapd-2_2 CVS] Missing calls to prot_free ?

Ken Murchison ken at oceana.com
Wed Mar 5 13:48:25 EST 2003


I fixed this in CVS.  We scrapped the prot stream, since it wasn't
needed.  I also changed the shutdown_file() prototype and used it in
lmtpengine.c

Thanks,
Ken

Christian Schulte wrote:
> 
>  From imap/global.c:
> 
> 550  /*
> 551   * Return contents of the shutdown file.  NULL = no file.
> 552   */
> 553  char *shutdown_file(void)
> 554  {
> 555      int fd;
> 556      struct protstream *shutdown_in;
> 557      static char shutdownfilename[1024] = "";
> 558      static char buf[1024];
> 559      char *p;
> 560
> 561      if (!shutdownfilename[0])
> 562          snprintf(shutdownfilename, sizeof(shutdownfilename),
> 563                   "%s/msg/shutdown", config_dir);
> 564      if ((fd = open(shutdownfilename, O_RDONLY, 0)) == -1) return NULL;
> 565
> 566      shutdown_in = prot_new(fd, 0, "SHUTDOWN");
> 567      prot_fgets(buf, sizeof(buf), shutdown_in);
> 568      if ((p = strchr(buf, '\r')) != NULL) *p = 0;
> 569      if ((p = strchr(buf, '\n')) != NULL) *p = 0;
> 570
> 571      syslog(LOG_WARNING, "%s, closing connection", buf);
> 572      prot_free(shutdown_in);
> 573      return buf;
> 574  }
> 
> I added line 572 because I think prot_free should be called somewhere
> after the prot_new call if the structure is not used furthermore. Is
> that right ?
> 
> The same in imap/lmtpengine.c:
> 
> 991        /* Only allow LHLO/NOOP/QUIT when there is a shutdown file */
> 992        if (!strchr("LlNnQq", buf[0]) &&
> 993            (shutdown_fd = open(shutdownfilename, O_RDONLY, 0)) != -1) {
> 994            struct protstream *shutdown_in = prot_new(shutdown_fd, 0,
> "LMTP_SHUTDOWNFILE");
> 995
> 996            prot_fgets(buf, sizeof(buf), shutdown_in);
> 997            if ((p = strchr(buf, '\r'))!=NULL) *p = 0;
> 998            if ((p = strchr(buf, '\n'))!=NULL) *p = 0;
> 999
> 1000            prot_printf(pout, "421 4.3.2 %s\r\n", buf);
> 1001            prot_flush(pout);
> 1002            prot_free(shutdown_in);
> 1003            func->shutdown(0);
> 1004        }
> 
> Here I added line 1002 but here I also do not know if this is correct!
> By the way: Shouldn't that call also the shutdownfile-function from
> global.c now ?
> 
> Then again in imap/lmtpengine.c:
> 
> 1377                rset:
> 1378                  if(msg->data) prot_free(msg->data);
> 1379                  if (msg) msg_free(msg);
> 1380                  msg_new(&msg);
> 1381
> 1382                  continue;
> 1383              }
> 1384              goto syntaxerr;
> 
> I added line 1378 and again I do not know if it was correct.
> 
> Finally: Did I totally misunderstand the sources or are these missing
> calls to prot_free nonrelevant ? Would be great if someone could comment
> on this!
> 
> --Christian--

-- 
Kenneth Murchison     Oceana Matrix Ltd.
Software Engineer     21 Princeton Place
716-662-8973 x26      Orchard Park, NY 14127
--PGP Public Key--    http://www.oceana.com/~ken/ksm.pgp




More information about the Info-cyrus mailing list