From d7920d694afb783e3abe538da3db03c8b6887764 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 2 Sep 2019 04:54:18 +0000 Subject: [PATCH] Don't create the security-related header fields if the assocated "client" object/struct doesn't have any meaningful data. Prevent this from happening: SenderTime 19700101000000Z SenderIpAddr SenderHostName SenderPort 0 --- src/sbbs3/postmsg.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/sbbs3/postmsg.cpp b/src/sbbs3/postmsg.cpp index 41ec13ec82..e952e22486 100644 --- a/src/sbbs3/postmsg.cpp +++ b/src/sbbs3/postmsg.cpp @@ -359,18 +359,24 @@ extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client) if(client->user!=NULL && (i=smb_hfield_str(msg,SENDERUSERID,client->user))!=SMB_SUCCESS) return(i); - if((i=smb_hfield_str(msg,SENDERTIME,xpDateTime_to_isoDateTimeStr(gmtime_to_xpDateTime(client->time) + if(client->time + && (i=smb_hfield_str(msg,SENDERTIME,xpDateTime_to_isoDateTimeStr(gmtime_to_xpDateTime(client->time) ,/* separators: */"","","", /* precision: */0 ,date,sizeof(date))))!=SMB_SUCCESS) return(i); - if((i=smb_hfield_str(msg,SENDERIPADDR,client->addr))!=SMB_SUCCESS) + if(*client->addr + && (i=smb_hfield_str(msg,SENDERIPADDR,client->addr))!=SMB_SUCCESS) return(i); - if((i=smb_hfield_str(msg,SENDERHOSTNAME,client->host))!=SMB_SUCCESS) + if(*client->host + && (i=smb_hfield_str(msg,SENDERHOSTNAME,client->host))!=SMB_SUCCESS) return(i); if(client->protocol!=NULL && (i=smb_hfield_str(msg,SENDERPROTOCOL,client->protocol))!=SMB_SUCCESS) return(i); - SAFEPRINTF(port,"%u",client->port); - return smb_hfield_str(msg,SENDERPORT,port); + if(client->port) { + SAFEPRINTF(port,"%u",client->port); + return smb_hfield_str(msg,SENDERPORT,port); + } + return SMB_SUCCESS; } /* Note: support MSG_BODY only, no tails or other data fields (dfields) */ -- GitLab