...
 
Commits (1)
  • Rob Swindell's avatar
    Don't allow forwarding-netmail loops · 48627415
    Rob Swindell authored
    Leave it to new users to do weird stuff and define a mail-forward loop. Outsmart them and don't allow forwarding when the destination is a local address (QWKnet, FidoNet, or Internet).
    48627415
......@@ -2971,6 +2971,7 @@ static void smtp_thread(void* arg)
if(startup->inbound_sound[0] && !(startup->options&MAIL_OPT_MUTE))
PlaySound(startup->inbound_sound, NULL, SND_ASYNC|SND_FILENAME);
#endif
SAFEPRINTF(domain_list,"%sdomains.cfg",scfg.ctrl_dir);
addr_len=sizeof(server_addr);
......@@ -4664,7 +4665,6 @@ static void smtp_thread(void* arg)
*cp=0;
dest_port=atoi(cp+1);
}
SAFEPRINTF(domain_list,"%sdomains.cfg",scfg.ctrl_dir);
if((stricmp(dest_host,scfg.sys_inetaddr)!=0
&& stricmp(dest_host,startup->host_name)!=0
&& findstr(dest_host,domain_list)==FALSE)
......@@ -4927,7 +4927,10 @@ static void smtp_thread(void* arg)
&& scfg.sys_misc&SM_FWDTONET
&& (user.misc&NETMAIL || forward)
&& tp!=NULL && smb_netaddr_type(user.netmail)==NET_INTERNET
&& !strstr(tp,scfg.sys_inetaddr)) {
&& stricmp(tp + 1, scfg.sys_inetaddr) != 0
&& stricmp(tp + 1, startup->host_name) != 0
&& findstr(tp + 1, domain_list)==FALSE
) {
lprintf(LOG_INFO,"%04d %s %s Forwarding to: %s"
,socket, client.protocol, client_id, user.netmail);
fprintf(rcptlst,"%s=%u\n",smb_hfieldtype(RECIPIENTNETTYPE),NET_INTERNET);
......
......@@ -1431,18 +1431,35 @@ bool sbbs_t::qnetmail(const char *into, const char *subj, long mode, smb_t* resm
extern "C" BOOL is_supported_netmail_addr(scfg_t* cfg, const char* addr)
{
const char* p;
fidoaddr_t faddr;
if((p = strchr(addr, '@')) == NULL)
return FALSE;
p++;
switch (smb_netaddr_type(addr)) {
case NET_FIDO:
return INT_TO_BOOL(cfg->total_faddrs && (cfg->netmail_misc&NMAIL_ALLOW));
if(!(cfg->netmail_misc&NMAIL_ALLOW))
return FALSE;
if(cfg->total_faddrs < 1)
return FALSE;
faddr = atofaddr(cfg, (char*)p);
for(int i = 0; i < cfg->total_faddrs; i++)
if(memcmp(&cfg->faddr[i], &faddr, sizeof(faddr)) == 0)
return FALSE;
return TRUE;
case NET_INTERNET:
return INT_TO_BOOL(cfg->inetmail_misc&NMAIL_ALLOW);
if(!(cfg->inetmail_misc&NMAIL_ALLOW))
return FALSE;
if(stricmp(p, cfg->sys_inetaddr) == 0)
return FALSE;
char domain_list[MAX_PATH + 1];
SAFEPRINTF(domain_list, "%sdomains.cfg", cfg->ctrl_dir);
return findstr(p, domain_list) == FALSE;
case NET_QWK:
{
char fulladdr[256] = "";
const char* p = strchr(addr, '@');
if(p == NULL)
return FALSE;
qwk_route(cfg, p + 1, fulladdr, sizeof(fulladdr)-1);
qwk_route(cfg, p, fulladdr, sizeof(fulladdr)-1);
return fulladdr[0] != 0;
}
default:
......