From 36785de6e56c5e2c49b386f73a136b62d845cb19 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Tue, 18 Jun 2002 18:52:48 +0000 Subject: [PATCH] Memory leak fixes --- mbcico/mbout.c | 1 + mbfido/forward.c | 6 ++++-- mbfido/ftn2rfc.c | 8 +++++--- mbfido/postnetmail.c | 4 +++- mbfido/rfc2ftn.c | 9 ++++++--- mbfido/scan.c | 5 ++++- mbfido/sendmail.c | 24 +++++++++++++----------- 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/mbcico/mbout.c b/mbcico/mbout.c index fc491ff6..c0f1b9aa 100644 --- a/mbcico/mbout.c +++ b/mbcico/mbout.c @@ -333,6 +333,7 @@ int main(int argc, char *argv[]) if (!do_quiet) printf("File attach %s is successfull", argv[4]); CreateSema((char *)"scanout"); + tidy_faddr(addr); die(0); } else { Fatal((char *)"File attach failed"); diff --git a/mbfido/forward.c b/mbfido/forward.c index bf627146..a146fe3c 100644 --- a/mbfido/forward.c +++ b/mbfido/forward.c @@ -51,7 +51,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl) char *subject = NULL, *temp, *fwdfile = NULL, *ticfile = NULL, fname[PATH_MAX], *ticname; FILE *fp, *fi, *net; char flavor; - faddr *dest, *routeto, *Fa, *Temp; + faddr *dest, *routeto, *Fa, *Temp, *ba; int i, z, n; time_t now, ftime; fa_list *tmp; @@ -226,8 +226,10 @@ void ForwardFile(fidoaddr Node, fa_list *sbl) now = time(NULL); subject = ctime(&now); Striplf(subject); - fprintf(fp, "Path %s %lu %s %s\r\n", ascfnode(bestaka_s(dest), 0x1f), + ba = bestaka_s(dest); + fprintf(fp, "Path %s %lu %s %s\r\n", ascfnode(ba, 0x1f), mktime(localtime(&now)), subject, tzname[0]); + tidy_faddr(ba); if (nodes.AdvTic) { /* diff --git a/mbfido/ftn2rfc.c b/mbfido/ftn2rfc.c index f3e2fef4..9549f84e 100644 --- a/mbfido/ftn2rfc.c +++ b/mbfido/ftn2rfc.c @@ -80,7 +80,7 @@ void fill_rlist(fa_list **fap, char *str) *q++='\0'; else q=p+strlen(p); - if ((ta=parsefaddr(p))) { + if ((ta = parsefaddr(p))) { if (ta->net == 0) ta->net=oldnet; else @@ -222,7 +222,7 @@ void substitute(char *buf) case ')': if (!inquotes && inbrackets) inbrackets--; break; default: break; } - if ((fa=parsefaddr(l))) { + if ((fa = parsefaddr(l))) { Syslog('m', "it is an ftn address: %s",ascfnode(fa,0x7f)); if (is_local(fa)) { Syslog('m', "it is local"); @@ -1069,7 +1069,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl sprintf(temp,"Reply-To: %s",p); Send(newsmode, temp); } else if ((p=hdr((char *)"REPLYTO",kmsg))) { - sprintf(temp,"Reply-To: %s\n",ascinode(parsefaddr(p),0xff)); + ta = parsefaddr(p); + sprintf(temp,"Reply-To: %s\n",ascinode(ta, 0xff)); + tidy_faddr(ta); Send(newsmode, temp); } diff --git a/mbfido/postnetmail.c b/mbfido/postnetmail.c index 55c99957..09432a4a 100644 --- a/mbfido/postnetmail.c +++ b/mbfido/postnetmail.c @@ -415,9 +415,11 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t now = time(NULL); tm = gmtime(&now); + ta = bestaka_s(t); fprintf(net, "\001Via %s @%d%02d%02d.%02d%02d%02d.00.UTC mbfido %s\r", - ascfnode(bestaka_s(t), 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, + ascfnode(ta, 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION); + tidy_faddr(ta); putc(0, net); fclose(net); diff --git a/mbfido/rfc2ftn.c b/mbfido/rfc2ftn.c index 3836609f..0fabba47 100644 --- a/mbfido/rfc2ftn.c +++ b/mbfido/rfc2ftn.c @@ -140,7 +140,7 @@ int rfc2ftn(FILE *fp, faddr *recipient) ftnmsg *fmsg = NULL; FILE *ofp; fa_list *sbl = NULL, *ptl = NULL, *tmpl; - faddr *ta; + faddr *ta, *fta; unsigned long svmsgid, svreply; int sot_kludge = FALSE, eot_kludge = FALSE, qp_or_base64 = FALSE, tinyorigin = FALSE; int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders; @@ -472,8 +472,11 @@ int rfc2ftn(FILE *fp, faddr *recipient) hdrsize += 15; if (newsmode) fprintf(ofp,"\1REPLYTO: %s UUCP\n", aka2str(msgs.Aka)); - else - fprintf(ofp,"\1REPLYTO: %s UUCP\n", ascfnode(bestaka_s(fmsg->to), 0x1f)); + else { + fta = bestaka_s(fmsg->to); + fprintf(ofp,"\1REPLYTO: %s UUCP\n", ascfnode(fta, 0x1f)); + tidy_faddr(fta); + } } else if ((p = hdr((char *)"Reply-To",msg))) { if ((ta = parsefaddr(p))) { if ((q = hdr((char *)"From",msg))) { diff --git a/mbfido/scan.c b/mbfido/scan.c index 02660070..56b6a926 100644 --- a/mbfido/scan.c +++ b/mbfido/scan.c @@ -817,7 +817,9 @@ void ExportNet(unsigned long MsgNum, int UUCPgate) /* * Check if this a netmail to our own local UUCP gate. */ - if ((!strcmp(Msg.To, "UUCP")) && (is_local(parsefnode(Msg.ToAddress)))) { + ta = parsefnode(Msg.ToAddress); + if ((!strcmp(Msg.To, "UUCP")) && (is_local(ta))) { + tidy_faddr(ta); most_debug = TRUE; Syslog('m', "We are the UUCP gate"); Syslog('m', "From %s FromAddress %s", Msg.From, Msg.FromAddress); @@ -892,6 +894,7 @@ void ExportNet(unsigned long MsgNum, int UUCPgate) fclose(fp); return; } + tidy_faddr(ta); if (UUCPgate) { memcpy(&Dest, &CFG.UUCPgate, sizeof(fidoaddr)); diff --git a/mbfido/sendmail.c b/mbfido/sendmail.c index 477d2eee..d1962fa6 100644 --- a/mbfido/sendmail.c +++ b/mbfido/sendmail.c @@ -132,19 +132,21 @@ FILE *SendMgrMail(faddr *t, int Keep, int FileAttach, char *bymgr, char *subj, c void CloseMail(FILE *qp, faddr *t) { - time_t Now; - struct tm *tm; + time_t Now; + struct tm *tm; + faddr *ta; - putc('\r', qp); - Now = time(NULL); - tm = gmtime(&Now); - fprintf(qp, "\001Via %s @%d%02d%02d.%02d%02d%02d.02.UTC %s\r", - ascfnode(bestaka_s(t), 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, + putc('\r', qp); + Now = time(NULL); + tm = gmtime(&Now); + ta = bestaka_s(t); + fprintf(qp, "\001Via %s @%d%02d%02d.%02d%02d%02d.02.UTC %s\r", + ascfnode(ta, 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION); - - putc(0, qp); - fclose(qp); - net_out++; + tidy_faddr(ta); + putc(0, qp); + fclose(qp); + net_out++; }