Commit e3e0e945 authored by rswindell's avatar rswindell
Browse files

Fix echomail loop-back from points for Dan Richter:

- When importing echomail packets and tossing to linked-nodes, don't loop
messages back to originating nodes, even if their address is not in the PATH or
SEEN-BYs.
- To get the full originating address of an echomail message (for loop-back
prevention), parse the Origin Line before tossing to links. If the Origin Line
cannot be parsed, log a warning message.
parent 58729012
/* fidodefs.h */
/* FidoNet constants, macros, and structure definitions */
/* $Id$ */
......@@ -41,12 +39,15 @@
#include "gen_defs.h"
#define FIDO_TLD ".fidonet" /* Fake TLD for gating netmail through SMTP */
#define FIDO_NAME_LEN 36 /* Includes '\0' terminator */
#define FIDO_SUBJ_LEN 72 /* Includes '\0' terminator */
#define FIDO_TIME_LEN 20 /* Includes '\0' terminator */
#define FIDO_PASS_LEN 8 /* Does NOT include '\0' terminator */
#define FIDO_AREATAG_LEN 35 /* Echo "areatag" (NOT including '\0') */
#define FIDO_ORIGIN_PREFIX_FORM_1 "\r * Origin: "
#define FIDO_ORIGIN_PREFIX_FORM_2 "\n * Origin: "
#define FIDO_NAME_LEN 36 /* Includes '\0' terminator */
#define FIDO_SUBJ_LEN 72 /* Includes '\0' terminator */
#define FIDO_TIME_LEN 20 /* Includes '\0' terminator */
#define FIDO_PASS_LEN 8 /* Does NOT include '\0' terminator */
#define FIDO_AREATAG_LEN 35 /* Echo "areatag" (NOT including '\0') */
#define FIDO_ORIGIN_PREFIX_LEN 12 /* Includes new-line character */
/* Attribute bits for fmsghdr_t.attr */
#define FIDO_PRIVATE (1<<0) /* Private message */
......
......@@ -559,6 +559,35 @@ const char* fmsghdr_destaddr_str(const fmsghdr_t* hdr)
return smb_faddrtoa(&addr, buf);
}
bool parse_origin(const char* fmsgbuf, fmsghdr_t* hdr)
{
char* p;
fidoaddr_t origaddr;
if((p = strstr(fmsgbuf, FIDO_ORIGIN_PREFIX_FORM_1)) == NULL)
p = strstr(fmsgbuf, FIDO_ORIGIN_PREFIX_FORM_2);
if(p == NULL)
return false;
p += FIDO_ORIGIN_PREFIX_LEN;
p = strrchr(p, '(');
if(p == NULL)
return false;
p++;
origaddr = atofaddr(p);
if(origaddr.zone == 0
|| origaddr.zone == 0xffff
|| origaddr.net == 0xffff
|| origaddr.node == 0xffff
|| origaddr.point == 0xffff)
return false;
hdr->origzone = origaddr.zone;
hdr->orignet = origaddr.net;
hdr->orignode = origaddr.node;
hdr->origpoint = origaddr.point;
return true;
}
bool parse_pkthdr(const fpkthdr_t* hdr, fidoaddr_t* orig_addr, fidoaddr_t* dest_addr, enum pkt_type* pkt_type)
{
fidoaddr_t orig;
......@@ -3198,9 +3227,9 @@ void gen_psb(addrlist_t *seenbys, addrlist_t *paths, const char *inbuf, uint16_t
if(!inbuf)
return;
fbuf=strstr((char *)inbuf,"\r * Origin: ");
fbuf=strstr(inbuf, FIDO_ORIGIN_PREFIX_FORM_1);
if(!fbuf)
fbuf=strstr((char *)inbuf,"\n * Origin: ");
fbuf=strstr(inbuf, FIDO_ORIGIN_PREFIX_FORM_2);
if(!fbuf)
fbuf=inbuf;
FREE_AND_NULL(seenbys->addr);
......@@ -3357,7 +3386,9 @@ void strip_psb(char *inbuf)
if(!inbuf)
return;
fbuf=strstr((char *)inbuf,"\r * Origin: ");
fbuf=strstr(inbuf, FIDO_ORIGIN_PREFIX_FORM_1);
if(!fbuf)
fbuf=strstr(inbuf, FIDO_ORIGIN_PREFIX_FORM_2);
if(!fbuf)
fbuf=inbuf;
if((p=strstr((char *)fbuf,"\rSEEN-BY:"))!=NULL)
......@@ -3465,6 +3496,11 @@ void pkt_to_pkt(const char *fbuf, area_t area, const fidoaddr_t* faddr
continue;
if(check_psb(&seenbys, area.link[u]))
continue;
if(fmsghdr.origzone == area.link[u].zone
&& fmsghdr.orignet == area.link[u].net
&& fmsghdr.orignode == area.link[u].node
&& fmsghdr.origpoint == area.link[u].point)
continue; /* Don't loop messages back to originator */
nodecfg_t* nodecfg = findnodecfg(&cfg, area.link[u],0);
if(nodecfg != NULL && nodecfg->passive)
continue;
......@@ -4750,6 +4786,10 @@ void import_packets(const char* inbound, nodecfg_t* inbox, bool secure)
}
}
if(!parse_origin(fmsgbuf, &hdr))
lprintf(LOG_WARNING, "%s: Failed to parse Origin Line in message from %s (%s) in packet from %s: %s"
,areatag, hdr.from, fmsghdr_srcaddr_str(&hdr), smb_faddrtoa(&pkt_orig,NULL), packet);
if(cfg.secure_echomail && cfg.area[i].sub!=INVALID_SUB) {
if(!area_is_linked(i,&pkt_orig)) {
lprintf(LOG_WARNING, "%s: Security violation - %s not in AREAS.BBS"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment