Commit 90f74d63 authored by rswindell's avatar rswindell
Browse files

New smb_getmsgtxt() mode bit to exclude text header fields from returned text

buffer (used by chksmb for message body and tail hash verification).
parent 697b4e4e
......@@ -80,11 +80,12 @@
#define SMB_ALL_REFS 0 /* Free all references to data */
#define GETMSGTXT_TAILS (1<<0) /* Get message tail(s) */
#define GETMSGTXT_NO_BODY (1<<1) /* Do not retrieve message body */
#define GETMSGTXT_BODY_ONLY 0
#define GETMSGTXT_TAIL_ONLY (GETMSGTXT_TAILS|GETMSGTXT_NO_BODY)
#define GETMSGTXT_ALL GETMSGTXT_TAILS
#define GETMSGTXT_TAILS (1<<0) /* Get message tail(s) */
#define GETMSGTXT_NO_BODY (1<<1) /* Don't retrieve message body */
#define GETMSGTXT_NO_HFIELDS (1<<2) /* Don't include text header fields */
#define GETMSGTXT_BODY_ONLY GETMSGTXT_NO_HFIELDS
#define GETMSGTXT_TAIL_ONLY (GETMSGTXT_TAILS|GETMSGTXT_NO_BODY|GETMSGTXT_NO_HFIELDS)
#define GETMSGTXT_ALL GETMSGTXT_TAILS
#define SMB_IS_OPEN(smb) ((smb)->shd_fp!=NULL)
......
......@@ -61,19 +61,21 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
}
*buf=0;
for(i=0;i<(uint)msg->total_hfields;i++) { /* comment headers are part of text */
if(msg->hfield[i].type!=SMB_COMMENT && msg->hfield[i].type!=SMTPSYSMSG)
continue;
str=(char*)msg->hfield_dat[i];
length=strlen(str)+2; /* +2 for crlf */
if((p=(char*)realloc(buf,l+length+1))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for comment buffer"
,l+length+1);
return(buf);
if(!(mode&GETMSGTXT_NO_HFIELDS)) {
for(i=0;i<(uint)msg->total_hfields;i++) { /* comment headers are part of text */
if(msg->hfield[i].type!=SMB_COMMENT && msg->hfield[i].type!=SMTPSYSMSG)
continue;
str=(char*)msg->hfield_dat[i];
length=strlen(str)+2; /* +2 for crlf */
if((p=(char*)realloc(buf,l+length+1))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for comment buffer"
,l+length+1);
return(buf);
}
buf=p;
l+=sprintf(buf+l,"%s\r\n",str);
}
buf=p;
l+=sprintf(buf+l,"%s\r\n",str);
}
for(i=0;i<(uint)msg->hdr.total_dfields;i++) {
......
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