Fixed memory leaks, code cleanup
This commit is contained in:
parent
747a87b393
commit
ee389b1a7a
@ -53,12 +53,8 @@ char pktpwd[9];
|
||||
int getheader(faddr *f, faddr *t, FILE *pkt, char *pname)
|
||||
{
|
||||
unsigned char buffer[0x3a];
|
||||
int i, pwdok;
|
||||
int capword, prodx;
|
||||
int major, minor = 0;
|
||||
int tome = FALSE;
|
||||
char *p, *prodn = NULL;
|
||||
char buf[5];
|
||||
int i, pwdok, capword, prodx, major, minor = 0, tome = FALSE;
|
||||
char *p, *prodn = NULL, *fa, *ta, buf[5];
|
||||
long year, month, day, hour, min, sec;
|
||||
|
||||
f->domain = NULL;
|
||||
@ -67,8 +63,7 @@ int getheader(faddr *f, faddr *t, FILE *pkt, char *pname)
|
||||
t->name = NULL;
|
||||
|
||||
/*
|
||||
* Read type 2+ packet header, see FSC-0039 version 4
|
||||
* and FTS-0001
|
||||
* Read type 2+ packet header, see FSC-0039 version 4 and FTS-0001
|
||||
*/
|
||||
if (fread(buffer, 1, 0x3a, pkt) != 0x3a) {
|
||||
WriteError("$Could not read header (%s)", pname);
|
||||
@ -142,18 +137,20 @@ int getheader(faddr *f, faddr *t, FILE *pkt, char *pname)
|
||||
pktfrom.point = 0;
|
||||
|
||||
for (i = 0; i < 40; i++) {
|
||||
if ((CFG.akavalid[i]) &&
|
||||
((t->zone == 0) || (t->zone == CFG.aka[i].zone)) &&
|
||||
(t->net == CFG.aka[i].net) &&
|
||||
(t->node == CFG.aka[i].node) &&
|
||||
if ((CFG.akavalid[i]) && ((t->zone == 0) || (t->zone == CFG.aka[i].zone)) &&
|
||||
(t->net == CFG.aka[i].net) && (t->node == CFG.aka[i].node) &&
|
||||
((!(capword & 0x0001)) || (t->point == CFG.aka[i].point)))
|
||||
tome = TRUE;
|
||||
}
|
||||
|
||||
fa = xstrcpy(ascfnode(f, 0x1f));
|
||||
ta = xstrcpy(ascfnode(t, 0x1f));
|
||||
Syslog('+', "Packet : %s type %s", pname, (capword & 0x0001) ? "2+":"stone-age");
|
||||
Syslog('+', "From : %s to %s", xstrcpy(ascfnode(f, 0x1f)), xstrcpy(ascfnode(t,0x1f)));
|
||||
Syslog('+', "From : %s to %s", fa, ta);
|
||||
Syslog('+', "Dated : %02u-%02u-%u %02u:%02u:%02u", day, month, year, hour, min, sec);
|
||||
Syslog('+', "Program : %s %d.%d", prodn, major, minor);
|
||||
free(ta);
|
||||
free(fa);
|
||||
|
||||
if (capword & 0x0001) {
|
||||
buf[0] = buffer[0x36];
|
||||
|
@ -676,9 +676,8 @@ int TossPkts(void)
|
||||
* Read all .pkt filenames, get the timestamp and add them
|
||||
* to the memory array for later sort on filedate.
|
||||
*/
|
||||
while((de = readdir(dp)))
|
||||
if ((strlen(de->d_name) == 12) &&
|
||||
(strncasecmp(de->d_name+8,".pkt",4) == 0)) {
|
||||
while ((de = readdir(dp)))
|
||||
if ((strlen(de->d_name) == 12) && (strncasecmp(de->d_name+8,".pkt",4) == 0)) {
|
||||
stat(de->d_name, &sbuf);
|
||||
fill_fdlist(&fdl, de->d_name, sbuf.st_mtime);
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ extern int echo_bad; /* Bad echomail */
|
||||
|
||||
void tidy_qualify(qualify **);
|
||||
void fill_qualify(qualify **, fidoaddr, int, int);
|
||||
void dlog_qualify(qualify **, char *);
|
||||
int EchoOut(fidoaddr, char *, char *, char *, FILE *, int, int, time_t);
|
||||
|
||||
|
||||
@ -100,7 +99,7 @@ int EchoOut(fidoaddr aka, char *toname, char *fromname, char *subj, FILE *fp, in
|
||||
}
|
||||
|
||||
rewind(fp);
|
||||
buf = calloc(2048, sizeof(char));
|
||||
buf = calloc(2049, sizeof(char));
|
||||
|
||||
while ((fgets(buf, 2048, fp)) != NULL) {
|
||||
Striplf(buf);
|
||||
@ -144,20 +143,6 @@ void fill_qualify(qualify **qal, fidoaddr aka, int orig, int insb)
|
||||
|
||||
|
||||
|
||||
void dlog_qualify(qualify **qal, char *msg)
|
||||
{
|
||||
qualify *tmpl;
|
||||
|
||||
for (tmpl = *qal; tmpl; tmpl = tmpl->next) {
|
||||
Syslog('m', "%s InSB=%s Snd=%s Org=%s",
|
||||
aka2str(tmpl->aka), tmpl->inseenby ? "True":"False",
|
||||
tmpl->send ? "True":"False",
|
||||
tmpl->orig ? "True":"False");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Post echomail message, forward if needed.
|
||||
* pkt_from, from, to, subj, orig, mdate, flags, cost, file
|
||||
@ -169,8 +154,7 @@ void dlog_qualify(qualify **qal, char *msg)
|
||||
* For echomail, the crc32 is calculated over the ^AREA kludge, subject,
|
||||
* message date, origin line, message id.
|
||||
*/
|
||||
int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
|
||||
time_t mdate, int flags, int cost, FILE *fp, int tonews)
|
||||
int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t mdate, int flags, int cost, FILE *fp, int tonews)
|
||||
{
|
||||
char *buf, *msgid = NULL, *reply = NULL, *p, *q, sbe[16];
|
||||
int First = TRUE, rc = 0, i, kludges = TRUE;
|
||||
@ -182,17 +166,6 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
|
||||
qualify *qal = NULL, *tmpq;
|
||||
FILE *nfp, *qp;
|
||||
|
||||
// Syslog('M', "Entering postecho, area %s %s", msgs.Tag, msgs.Name);
|
||||
// Syslog('M', "p_from: %s", ascfnode(p_from, 0xff));
|
||||
// Syslog('M', "from : %s", ascfnode(f, 0xff));
|
||||
// Syslog('M', "to : %s", ascfnode(t, 0xff));
|
||||
// Syslog('M', "subj : %s", printable(subj, 0));
|
||||
// Syslog('M', "origin: %s", orig);
|
||||
// Syslog('M', "date : %s", rfcdate(mdate));
|
||||
// Syslog('M', "flags : %08x", flags);
|
||||
// Syslog('M', "cost : %d", cost);
|
||||
// Syslog('M', "tonews: %s", tonews ? "True":"False");
|
||||
|
||||
memset(&Link, 0, sizeof(Link));
|
||||
crc = 0xffffffff;
|
||||
echo_in++;
|
||||
@ -248,13 +221,12 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
|
||||
/*
|
||||
* Read the message for kludges we need.
|
||||
*/
|
||||
buf = calloc(2048, sizeof(char));
|
||||
buf = calloc(2049, sizeof(char));
|
||||
First = TRUE;
|
||||
rewind(fp);
|
||||
while ((fgets(buf, 2048, fp)) != NULL) {
|
||||
|
||||
Striplf(buf);
|
||||
// Syslogp('M', printable(buf, 0));
|
||||
|
||||
if (First && (!strncmp(buf, "AREA:", 5))) {
|
||||
crc = upd_crc32(buf, crc, strlen(buf));
|
||||
@ -330,10 +302,8 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
|
||||
*/
|
||||
if ((msgs.Aka.zone == t->zone) && (msgs.Aka.net == t->net)) {
|
||||
for (i = 0; i < 40; i++) {
|
||||
if ((CFG.akavalid[i]) &&
|
||||
(CFG.aka[i].zone == t->zone) &&
|
||||
(CFG.aka[i].net == t->net) &&
|
||||
(CFG.aka[i].node == t->node))
|
||||
if ((CFG.akavalid[i]) && (CFG.aka[i].zone == t->zone) &&
|
||||
(CFG.aka[i].net == t->net) && (CFG.aka[i].node == t->node))
|
||||
bad = FALSE; /* Undo the result */
|
||||
}
|
||||
}
|
||||
@ -548,9 +518,7 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
|
||||
fprintf(qp, "From: %s@%s\n", q, ascinode(f, 0x1f));
|
||||
fprintf(qp, "Subject: %s\n", Msg.Subject);
|
||||
fprintf(qp, "To: %s\n", Msg.To);
|
||||
|
||||
// FIXME: hier nog X-...-To: ??
|
||||
|
||||
free(q);
|
||||
fprintf(qp, "\n");
|
||||
}
|
||||
fprintf(qp, "%s\n", buf);
|
||||
|
@ -151,7 +151,7 @@ int storeecho(faddr *f, faddr *t, time_t mdate, int flags, char *subj, char *msg
|
||||
* If not a bad or dupe message, eat the first
|
||||
* line (AREA:tag).
|
||||
*/
|
||||
buf = calloc(2048, sizeof(char));
|
||||
buf = calloc(2049, sizeof(char));
|
||||
rewind(fp);
|
||||
if (!dupe && !bad)
|
||||
fgets(buf , 2048, fp);
|
||||
|
Reference in New Issue
Block a user