diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c index 3f3ffd75da548a55ab9d80163090209199e3c1e1..11512f0c0cf77a4456d769dc8b1be187b08f00c8 100644 --- a/src/smblib/smblib.c +++ b/src/smblib/smblib.c @@ -121,6 +121,7 @@ int SMBCALL smb_open(smb_t* smb) if((i=smb_open_fp(smb,&smb->shd_fp,SH_DENYNO))!=SMB_SUCCESS) return(i); + memset(&(smb->status),0,sizeof(smb->status)); if(filelength(fileno(smb->shd_fp))>=sizeof(smbhdr_t)) { setvbuf(smb->shd_fp,NULL,_IONBF,SHD_BLOCK_LEN); if(smb_locksmbhdr(smb)!=SMB_SUCCESS) { @@ -1499,8 +1500,8 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage) /****************************************************************************/ /****************************************************************************/ -int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage - ,ushort attr, ushort xlat, const uchar* body, const uchar* tail) +int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, BOOL dupechk + ,ushort xlat, const uchar* body, const uchar* tail) { uchar* lzhbuf=NULL; long lzhlen; @@ -1522,8 +1523,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage } if(filelength(fileno(smb->shd_fp))<1) { /* Create it if it doesn't exist */ - memset(&smb->status,0,sizeof(smb->status)); - smb->status.attr=attr; + /* smb->status.max_crcs, max_msgs, max_age, and attr should be pre-initialized */ if((retval=smb_create(smb))!=SMB_SUCCESS) return(retval); } @@ -1543,7 +1543,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage hashes=smb_msghashes(smb,msg,body); - if(smb_findhash(smb, hashes, &found, /* update? */FALSE)==SMB_SUCCESS) { + if(dupechk && smb_findhash(smb, hashes, &found, /* update? */FALSE)==SMB_SUCCESS) { safe_snprintf(smb->last_error,sizeof(smb->last_error) ,"duplicate %s hash found (message #%lu)" ,smb_hashsource(found.source), found.number); @@ -1561,7 +1561,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage bodylen--; /* Calculate CRC-32 of message text (before encoding, if any) */ - if(smb->status.max_crcs) { + if(smb->status.max_crcs && dupechk) { for(l=0;l<bodylen;l++) crc=ucrc32(body[l],crc); crc=~crc; diff --git a/src/smblib/smblib.h b/src/smblib/smblib.h index 48b687e028b3ddc5f1af699a89ef3e7661b7a03f..b32fd99c7aa844a04228ade4b4a086e466ac6bbe 100644 --- a/src/smblib/smblib.h +++ b/src/smblib/smblib.h @@ -139,8 +139,8 @@ SMBEXPORT char* SMBCALL smb_hfieldtype(ushort type); SMBEXPORT ushort SMBCALL smb_hfieldtypelookup(const char*); SMBEXPORT char* SMBCALL smb_dfieldtype(ushort type); SMBEXPORT int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage); -SMBEXPORT int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage - ,ushort attr, ushort xlat, const uchar* body, const uchar* tail); +SMBEXPORT int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, BOOL dupechk + ,ushort xlat, const uchar* body, const uchar* tail); SMBEXPORT int SMBCALL smb_putmsg(smb_t* smb, smbmsg_t* msg); SMBEXPORT int SMBCALL smb_putmsgidx(smb_t* smb, smbmsg_t* msg); SMBEXPORT int SMBCALL smb_putmsghdr(smb_t* smb, smbmsg_t* msg);