/* ------------------------------------------------------ **
* smb_header.c
* ------------------------------------------------------ **
*/
#include "smb_header.h"
const char *smb_hdrSMBString = "\xFFSMB";
int smb_hdrInit( uchar *bufr, int bsize )
/* ---------------------------------------------------- **
* Initialize an empty header structure.
* Returns -1 on error, the SMB header size on success.
* ---------------------------------------------------- **
*/
{
int i;
if( bsize < SMB_HDR_SIZE )
return( -1 );
for( i = 0; i < 4; i++ )
bufr[i] = smb_hdrSMBString[i];
for( i = 4; i < SMB_HDR_SIZE; i++ )
bufr[i] = '\0';
return( SMB_HDR_SIZE );
} /* smb_hdrInit */
int smb_hdrCheck( uchar *bufr, int bsize )
/* ---------------------------------------------------- **
* Perform some quick checks on a received buffer to
* make sure it's safe to read. This function returns
* a negative value if the SMB header is invalid.
* ---------------------------------------------------- **
*/
{
int i;
if( NULL == bufr )
return( -1 );
if( bsize < SMB_HDR_SIZE )
return( -2 );
for( i = 0; i < 4; i++ )
if( bufr[i] != smb_hdrSMBString[i] )
return( -3 );
return( SMB_HDR_SIZE );
} /* smb_hdrCheck */
|
$Revision: 1.2 $ $Date: 2002/11/18 02:15:54 $ |
Copyright © 2002 Christopher R. Hertel Released under the terms of the LGPL |