Fixed several memory leaks in mbfido

This commit is contained in:
Michiel Broek 2002-06-17 20:36:06 +00:00
parent 3cc5a6fa3a
commit 25ca17d6f9
9 changed files with 112 additions and 51 deletions

View File

@ -38,6 +38,7 @@ v0.35.01 05-Jun-2002
mbfido:
When creating uplink area requests the from aka used is now
the aka defined in the group.
Removed several memory leaks again.
mbfile:
Added -v commandline switch to supress virus checking for the

View File

@ -124,7 +124,7 @@ void A_List(faddr *t, char *replyid, int Notify)
char *temp, *Group, *subject;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[5];
faddr *f, *g;
faddr *f, *g, *Temp;
sysconnect System;
long msgptr;
fpos_t fileptr,fileptr1,fileptr2;
@ -209,7 +209,9 @@ void A_List(faddr *t, char *replyid, int Notify)
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
Temp = fido2faddr(mgroup.UseAka);
g = bestaka_s(Temp);
tidy_faddr(Temp);
if ((!strcmp(mgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
@ -296,7 +298,7 @@ void A_Flow(faddr *t, char *replyid, int Notify)
char *temp, *Group, *subject;
int i, First = TRUE, Cons;
char Stat[2];
faddr *f, *g;
faddr *f, *g, *Temp;
sysconnect System;
time_t Now;
struct tm *tt;
@ -379,7 +381,9 @@ void A_Flow(faddr *t, char *replyid, int Notify)
plm = plw = plt = rlm = rlw = rlt = 0;
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
Temp = fido2faddr(mgroup.UseAka);
g = bestaka_s(Temp);
tidy_faddr(Temp);
if ((!strcmp(mgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
@ -521,7 +525,7 @@ void A_Disconnect(faddr *t, char *Area, FILE *tmp)
{
int i, First;
char *Group;
faddr *b;
faddr *b, *Temp;
sysconnect Sys;
Syslog('+', "AreaMgr: \"%s\"", Area);
@ -556,7 +560,9 @@ void A_Disconnect(faddr *t, char *Area, FILE *tmp)
}
b = bestaka_s(t);
i = metric(b, fido2faddr(msgs.Aka));
Temp = fido2faddr(msgs.Aka);
i = metric(b, Temp);
tidy_faddr(Temp);
Syslog('m', "Aka match level is %d", i);
if (i >= METRIC_NET) {
@ -610,7 +616,7 @@ void A_Connect(faddr *t, char *Area, FILE *tmp)
{
int i, First;
char *Group, *temp;
faddr *b;
faddr *b, *Temp;
sysconnect Sys;
FILE *gp;
@ -684,7 +690,9 @@ void A_Connect(faddr *t, char *Area, FILE *tmp)
}
b = bestaka_s(t);
i = metric(b, fido2faddr(msgs.Aka));
Temp = fido2faddr(msgs.Aka);
i = metric(b, Temp);
tidy_faddr(Temp);
Syslog('m', "Aka match level is %d", i);
if (i >= METRIC_NET) {
@ -737,7 +745,7 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
{
FILE *mp, *gp;
char *Group, *temp;
faddr *f;
faddr *f, *Temp;
int i, Link, First = TRUE, Cons;
sysconnect Sys;
long Pos;
@ -792,15 +800,18 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
fseek(mp, msgshdr.hdrsize, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) {
Temp = fido2faddr(msgs.Aka);
if ((!strcmp(Group, msgs.Group)) && (msgs.Active) && (!msgs.Mandatory) && strlen(msgs.Tag) &&
((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS) || (msgs.Type == LIST)) &&
(metric(fido2faddr(msgs.Aka), f) < METRIC_NET)) {
(metric(Temp, f) < METRIC_NET)) {
if (Connect) {
Link = FALSE;
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, mp);
if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL)
tidy_faddr(Temp);
Temp = fido2faddr(Sys.aka);
if (metric(Temp, t) == METRIC_EQUAL)
Link = TRUE;
}
if (!Link) {
@ -829,7 +840,9 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
} else {
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, mp);
if ((metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) && (!Sys.cutoff)) {
tidy_faddr(Temp);
Temp = fido2faddr(Sys.aka);
if ((metric(Temp, t) == METRIC_EQUAL) && (!Sys.cutoff)) {
memset(&Sys, 0, sizeof(Sys));
fseek(mp, - sizeof(Sys), SEEK_CUR);
fwrite(&Sys, sizeof(Sys), 1, mp);
@ -844,6 +857,7 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
}
} else
fseek(mp, msgshdr.syssize, SEEK_CUR);
tidy_faddr(Temp);
}
}
}
@ -872,7 +886,7 @@ void A_Pause(faddr *, int, FILE *);
void A_Pause(faddr *t, int Pause, FILE *tmp)
{
FILE *mp;
faddr *f;
faddr *f, *Temp;
int i, Cons;
sysconnect Sys;
char *temp;
@ -900,7 +914,8 @@ void A_Pause(faddr *t, int Pause, FILE *tmp)
if (msgs.Active) {
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, mp);
if ((metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) && (!Sys.cutoff)) {
Temp = fido2faddr(Sys.aka);
if ((metric(Temp, t) == METRIC_EQUAL) && (!Sys.cutoff)) {
Sys.pause = Pause;
fseek(mp, - sizeof(Sys), SEEK_CUR);
fwrite(&Sys, sizeof(Sys), 1, mp);
@ -910,6 +925,7 @@ void A_Pause(faddr *t, int Pause, FILE *tmp)
MsgResult("areamgr.responses",tmp);
a_list = TRUE;
}
tidy_faddr(Temp);
}
} else {
fseek(mp, msgshdr.syssize, SEEK_CUR);

View File

@ -93,6 +93,7 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
long offset, AreaNr;
int i, rc = 0, Found = FALSE;
sysconnect System;
faddr *From, *To;
temp = calloc(PATH_MAX, sizeof(char));
Syslog('f', "Checking file group \"%s\" \"%s\"", fgroup.Name, fgroup.Comment);
@ -188,13 +189,20 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
*/
if (SendUplink) {
sprintf(temp, "+%s", Area);
if (UplinkRequest(fido2faddr(fgroup.UpLink), fido2faddr(fgroup.UseAka), TRUE, temp)) {
From = fido2faddr(fgroup.UseAka);
To = fido2faddr(fgroup.UpLink);
if (UplinkRequest(To, From, TRUE, temp)) {
WriteError("Can't send netmail to uplink");
fclose(ap);
free(buf);
free(temp);
tidy_faddr(From);
tidy_faddr(To);
return 1;
}
tidy_faddr(From);
tidy_faddr(To);
}
Syslog('f', "Netmail ready");

View File

@ -94,6 +94,7 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
long offset;
int i, rc = 0;
sysconnect System;
faddr *From, *To;
temp = calloc(PATH_MAX, sizeof(char));
Syslog('m', "Checking echogroup %s %s", mgroup.Name, mgroup.Comment);
@ -121,13 +122,19 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
*/
if (SendUplink) {
sprintf(temp, "+%s", Area);
if (UplinkRequest(fido2faddr(mgroup.UpLink), fido2faddr(mgroup.UseAka), FALSE, temp)) {
From = fido2faddr(mgroup.UseAka);
To = fido2faddr(mgroup.UpLink);
if (UplinkRequest(To, From, FALSE, temp)) {
WriteError("Can't send netmail to uplink");
fclose(ap);
free(buf);
free(temp);
tidy_faddr(From);
tidy_faddr(To);
return 1;
}
tidy_faddr(From);
tidy_faddr(To);
}
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));

View File

@ -116,7 +116,7 @@ void F_List(faddr *t, char *replyid, int Notify)
char *temp, *Group, *subject;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[4];
faddr *f, *g;
faddr *f, *g, *Temp;
sysconnect System;
long msgptr;
fpos_t fileptr,fileptr1,fileptr2;
@ -200,7 +200,8 @@ void F_List(faddr *t, char *replyid, int Notify)
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(fgroup.UseAka));
Temp = fido2faddr(fgroup.UseAka);
g = bestaka_s(Temp);
if ((!strcmp(fgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
@ -260,6 +261,7 @@ void F_List(faddr *t, char *replyid, int Notify)
}
MacroRead(fi, qp);
}
tidy_faddr(Temp);
}
}
@ -352,7 +354,7 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
{
int i, First;
char *Group;
faddr *b;
faddr *b, *Temp;
sysconnect Sys;
Syslog('+', "FileMgr: %s", Area);
@ -387,7 +389,9 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
}
b = bestaka_s(t);
i = metric(b, fido2faddr(tic.Aka));
Temp = fido2faddr(tic.Aka);
i = metric(b, Temp);
tidy_faddr(Temp);
Syslog('m', "Aka match level is %d", i);
if (i >= METRIC_NET) {
@ -441,7 +445,7 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
{
int i, First;
char *Group, *temp;
faddr *b;
faddr *b, *Temp;
sysconnect Sys;
FILE *gp;
@ -515,7 +519,9 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
}
b = bestaka_s(t);
i = metric(b, fido2faddr(tic.Aka));
Temp = fido2faddr(tic.Aka);
i = metric(b, Temp);
tidy_faddr(Temp);
Syslog('m', "Aka match level is %d", i);
if (i >= METRIC_NET) {
@ -567,7 +573,7 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
{
FILE *fp, *gp;
char *Group, *temp;
faddr *f;
faddr *f, *Temp;
int i, Link, First = TRUE, Cons;
sysconnect Sys;
long Pos;
@ -618,14 +624,17 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
fseek(fp, tichdr.hdrsize, SEEK_SET);
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
Temp = fido2faddr(tic.Aka);
if ((!strcmp(Group, tic.Group)) && tic.Active && strlen(tic.Name) &&
(metric(fido2faddr(tic.Aka), f) < METRIC_NET)) {
(metric(Temp, f) < METRIC_NET)) {
if (Connect) {
Link = FALSE;
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, fp);
if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL)
tidy_faddr(Temp);
Temp = fido2faddr(Sys.aka);
if (metric(Temp, t) == METRIC_EQUAL)
Link = TRUE;
}
if (!Link) {
@ -653,7 +662,9 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
} else {
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, fp);
if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) {
tidy_faddr(Temp);
Temp = fido2faddr(Sys.aka);
if (metric(Temp, t) == METRIC_EQUAL) {
memset(&Sys, 0, sizeof(Sys));
fseek(fp, - sizeof(Sys), SEEK_CUR);
fwrite(&Sys, sizeof(Sys), 1, fp);
@ -668,6 +679,7 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
}
} else
fseek(fp, tichdr.syssize, SEEK_CUR);
tidy_faddr(Temp);
}
}
}
@ -696,7 +708,7 @@ void F_Pause(faddr *, int, FILE *);
void F_Pause(faddr *t, int Pause, FILE *tmp)
{
FILE *fp;
faddr *f;
faddr *f, *Temp;
int i, Cons;
sysconnect Sys;
char *temp;
@ -723,7 +735,8 @@ void F_Pause(faddr *t, int Pause, FILE *tmp)
if (tic.Active) {
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, fp);
if ((metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) && (!Sys.cutoff)) {
Temp = fido2faddr(Sys.aka);
if ((metric(Temp, t) == METRIC_EQUAL) && (!Sys.cutoff)) {
Sys.pause = Pause;
fseek(fp, - sizeof(Sys), SEEK_CUR);
fwrite(&Sys, sizeof(Sys), 1, fp);
@ -733,6 +746,7 @@ void F_Pause(faddr *t, int Pause, FILE *tmp)
MsgResult("filemgr.responses",tmp);
f_list = TRUE;
}
tidy_faddr(Temp);
}
} else {
fseek(fp, tichdr.syssize, SEEK_CUR);

View File

@ -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;
faddr *dest, *routeto, *Fa, *Temp;
int i, z, n;
time_t now, ftime;
fa_list *tmp;
@ -114,11 +114,6 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
dest = fido2faddr(Node);
attach(*routeto, fwdfile, LEAVE, flavor);
// if (strlen(CFG.dospath))
// subject = xstrcpy(Unix2Dos(fwdfile));
// else
// subject = xstrcpy(fwdfile);
ticfile = calloc(PATH_MAX, sizeof(char));
ticname = calloc(15, sizeof(char));
if (nodes.Tic) {
@ -133,7 +128,8 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
* Send netmail message if the node has it turned on.
*/
if (nodes.Message) {
if ((net = SendMgrMail(fido2faddr(Node), CFG.ct_KeepMgr, TRUE, (char *)"Filemgr", subject, NULL)) != NULL) {
Temp = fido2faddr(Node);
if ((net = SendMgrMail(Temp, CFG.ct_KeepMgr, TRUE, (char *)"Filemgr", subject, NULL)) != NULL) {
if ((fi = OpenMacro("forward.tic", nodes.Language, FALSE)) != NULL) {
ftime = TIC.FileDate;
MacroVars("a", "s", TIC.TicIn.Area);
@ -158,11 +154,12 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
MacroVars("l", "s", TIC.TicIn.Replace);
MacroRead(fi, net);
fprintf(net, "%s\r", TearLine());
CloseMail(net, fido2faddr(Node));
CloseMail(net, Temp);
}
} else {
WriteError("$Can't create netmail");
}
tidy_faddr(Temp);
}
free(subject);

View File

@ -99,7 +99,7 @@ void WriteMailGroups(FILE *fp, faddr *f)
int Count = 0, First = TRUE;
char *Group, *temp;
FILE *gp,*fi;
faddr *g;
faddr *g, *Temp;
fpos_t fileptr;
if ((fi = OpenMacro("areamgr.group", nodes.Language, FALSE)) == NULL)
@ -127,7 +127,8 @@ void WriteMailGroups(FILE *fp, faddr *f)
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
Temp = fido2faddr(mgroup.UseAka);
g = bestaka_s(Temp);
if ((!strcmp(mgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
MacroVars("gh", "ss", mgroup.Name, mgroup.Comment);
@ -136,6 +137,7 @@ void WriteMailGroups(FILE *fp, faddr *f)
Count++;
break;
}
tidy_faddr(Temp);
}
}
@ -156,7 +158,7 @@ void WriteFileGroups(FILE *fp, faddr *f)
int Count = 0, First = TRUE;
char *Group, *temp;
FILE *gp, *fi;
faddr *g;
faddr *g, *Temp;
fpos_t fileptr;
if ((fi = OpenMacro("filemgr.group", nodes.Language, FALSE)) == NULL)
@ -184,7 +186,8 @@ void WriteFileGroups(FILE *fp, faddr *f)
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(fgroup.UseAka));
Temp = fido2faddr(fgroup.UseAka);
g = bestaka_s(Temp);
if ((!strcmp(fgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
MacroVars("gh", "ss", fgroup.Name, fgroup.Comment );
@ -193,6 +196,7 @@ void WriteFileGroups(FILE *fp, faddr *f)
Count++;
break;
}
tidy_faddr(Temp);
}
}
@ -502,6 +506,7 @@ int Areas(void)
AreaList *alist = NULL, *tmp;
int i, count = 0, Found;
sysconnect System;
faddr *From, *To;
Syslog('+', "Process areas taglists");
@ -685,11 +690,15 @@ int Areas(void)
* Sent one uplink command with additions and deletions
*/
if (mgroup.UpLink.zone) {
if (UplinkRequest(fido2faddr(mgroup.UpLink), fido2faddr(mgroup.UseAka), FALSE, cmd)) {
From = fido2faddr(mgroup.UseAka);
To = fido2faddr(mgroup.UpLink);
if (UplinkRequest(To, From, FALSE, cmd)) {
WriteError("Uplink request failed");
} else {
Syslog('+', "AreaMgr request sent to %s", aka2str(mgroup.UpLink));
}
tidy_faddr(From);
tidy_faddr(To);
} else {
Syslog('+', "No uplink defined, not sending a AreaMgr request");
}
@ -939,11 +948,15 @@ int Areas(void)
* Sent one uplink command with additions and deletions
*/
if (fgroup.UpLink.zone) {
if (UplinkRequest(fido2faddr(fgroup.UpLink), fido2faddr(fgroup.UseAka), TRUE, cmd)) {
From = fido2faddr(fgroup.UseAka);
To = fido2faddr(fgroup.UpLink);
if (UplinkRequest(To, From, TRUE, cmd)) {
WriteError("Uplink request failed");
} else {
Syslog('+', "AreaMgr request sent to %s", aka2str(fgroup.UpLink));
}
tidy_faddr(From);
tidy_faddr(To);
} else {
Syslog('+', "No uplink defined, not sending a FileMgr request");
}

View File

@ -213,7 +213,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
char *ftnfrom=NULL;
static ftnmsg *tmsg;
int needreplyaddr = 1;
faddr *tmp;
faddr *tmp, *tmp2;
tmsg=(ftnmsg *)malloc(sizeof(ftnmsg));
memset(tmsg, 0, sizeof(ftnmsg));
@ -422,9 +422,11 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
if (tmsg->from)
Syslog('m', "From address was%s distinguished as ftn", tmsg->from ? "" : " not");
if (newsmode)
bestaka = bestaka_s(fido2faddr(msgs.Aka));
else
if (newsmode) {
tmp2 = fido2faddr(msgs.Aka);
bestaka = bestaka_s(tmp2);
tidy_faddr(tmp2);
} else
bestaka = bestaka_s(tmsg->to);
if ((tmsg->from == NULL) && (bestaka)) {

View File

@ -59,6 +59,7 @@ int Notify(char *Options)
FILE *np;
char *temp, Opt[44];
int i;
faddr *Tmp;
Syslog('+', "Notify \"%s\"", Options);
@ -139,13 +140,15 @@ int Notify(char *Options)
fflush(stdout);
}
Tmp = fido2faddr(nodes.Aka[i]);
if (i == 0) {
F_Status(fido2faddr(nodes.Aka[i]), NULL);
A_Status(fido2faddr(nodes.Aka[i]), NULL);
F_Status(Tmp, NULL);
A_Status(Tmp, NULL);
}
F_List(fido2faddr(nodes.Aka[i]), NULL, TRUE);
A_List(fido2faddr(nodes.Aka[i]), NULL, TRUE);
A_Flow(fido2faddr(nodes.Aka[i]), NULL, TRUE);
F_List(Tmp, NULL, TRUE);
A_List(Tmp, NULL, TRUE);
A_Flow(Tmp, NULL, TRUE);
tidy_faddr(Tmp);
notify++;
}
}