mirror of
https://github.com/samba-team/samba.git
synced 2024-12-29 11:21:54 +03:00
proto.h:
- recreated, as usual. smb.h: - added RPC_HDR structure - the 18 byte MSRPC header smbparse.c: - added smb_io_rpc_hdr() function to read/write the RPC_HDR structure. util.c: - added align2, align4, align_offset functions. - added skip_unicode_string, unistrcpy, unistrncpy functions. - modified unistrcpy and unistrncpy to return the number of unicode characters returned, effectively making skip_unicode_string redundant.
This commit is contained in:
parent
b0ffd75acf
commit
b0ad811cda
@ -565,7 +565,9 @@ void sync_browse_lists(struct subnet_record *d, struct work_record *work,
|
|||||||
|
|
||||||
/*The following definitions come from params.c */
|
/*The following definitions come from params.c */
|
||||||
|
|
||||||
BOOL pm_process(char *pszFileName,BOOL (*sfunc)(char *),BOOL (*pfunc)(char *,char *));
|
BOOL pm_process( char *FileName,
|
||||||
|
BOOL (*sfunc)(char *),
|
||||||
|
BOOL (*pfunc)(char *, char *) );
|
||||||
|
|
||||||
/*The following definitions come from password.c */
|
/*The following definitions come from password.c */
|
||||||
|
|
||||||
@ -986,5 +988,12 @@ void file_unlock(int fd);
|
|||||||
BOOL is_myname(char *s);
|
BOOL is_myname(char *s);
|
||||||
void set_remote_arch(enum remote_arch_types type);
|
void set_remote_arch(enum remote_arch_types type);
|
||||||
enum remote_arch_types get_remote_arch();
|
enum remote_arch_types get_remote_arch();
|
||||||
|
char *skip_unicode_string(char *buf,int n);
|
||||||
|
char *unistr(char *buf);
|
||||||
|
int unistrncpy(char *dst, char *src, int len);
|
||||||
|
int unistrcpy(char *dst, char *src);
|
||||||
void fstrcpy(char *dest, char *src);
|
void fstrcpy(char *dest, char *src);
|
||||||
void pstrcpy(char *dest, char *src);
|
void pstrcpy(char *dest, char *src);
|
||||||
|
char *align4(char *q, char *base);
|
||||||
|
char *align2(char *q, char *base);
|
||||||
|
char *align_offset(char *q, char *base, int align_offset);
|
||||||
|
@ -80,6 +80,10 @@ typedef short int16;
|
|||||||
typedef int int32;
|
typedef int int32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef uint8
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef uint16
|
#ifndef uint16
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
#endif
|
#endif
|
||||||
@ -416,7 +420,7 @@ typedef struct gid_info
|
|||||||
|
|
||||||
} DOM_GID;
|
} DOM_GID;
|
||||||
|
|
||||||
/* RPC_HEADER - ms rpc header */
|
/* RPC_HDR - ms rpc header */
|
||||||
typedef struct rpc_hdr_info
|
typedef struct rpc_hdr_info
|
||||||
{
|
{
|
||||||
uint8 major; /* 5 - RPC major version */
|
uint8 major; /* 5 - RPC major version */
|
||||||
@ -431,7 +435,7 @@ typedef struct rpc_hdr_info
|
|||||||
uint16 context_id; /* 0 - presentation context identifier */
|
uint16 context_id; /* 0 - presentation context identifier */
|
||||||
uint8 cancel_count; /* 0 - cancel count */
|
uint8 cancel_count; /* 0 - cancel count */
|
||||||
uint8 reserved; /* 0 - reserved */
|
uint8 reserved; /* 0 - reserved */
|
||||||
} RPC_HEADER;
|
} RPC_HDR;
|
||||||
|
|
||||||
|
|
||||||
struct smb_passwd {
|
struct smb_passwd {
|
||||||
|
@ -4182,6 +4182,80 @@ enum remote_arch_types get_remote_arch()
|
|||||||
return ra_type;
|
return ra_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
skip past some unicode strings in a buffer
|
||||||
|
********************************************************************/
|
||||||
|
char *skip_unicode_string(char *buf,int n)
|
||||||
|
{
|
||||||
|
while (n--)
|
||||||
|
{
|
||||||
|
while (*buf)
|
||||||
|
buf += 2;
|
||||||
|
buf += 2;
|
||||||
|
}
|
||||||
|
return(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
Return a ascii version of a unicode string
|
||||||
|
Hack alert: uses fixed buffer and only handles ascii strings
|
||||||
|
********************************************************************/
|
||||||
|
#define MAXUNI 1024
|
||||||
|
char *unistr(char *buf)
|
||||||
|
{
|
||||||
|
static char lbufs[8][MAXUNI];
|
||||||
|
static int nexti;
|
||||||
|
char *lbuf = lbufs[nexti];
|
||||||
|
char *p;
|
||||||
|
nexti = (nexti+1)%8;
|
||||||
|
for (p = lbuf; *buf && p -lbuf < MAXUNI-2; p++, buf += 2)
|
||||||
|
*p = *buf;
|
||||||
|
*p = 0;
|
||||||
|
return lbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
strncpy for unicode strings
|
||||||
|
********************************************************************/
|
||||||
|
int unistrncpy(char *dst, char *src, int len)
|
||||||
|
{
|
||||||
|
int num_wchars = 0;
|
||||||
|
|
||||||
|
while (*src && len > 0)
|
||||||
|
{
|
||||||
|
*dst++ = *src++;
|
||||||
|
*dst++ = *src++;
|
||||||
|
len--;
|
||||||
|
num_wchars++;
|
||||||
|
}
|
||||||
|
*dst++ = 0;
|
||||||
|
*dst++ = 0;
|
||||||
|
|
||||||
|
return num_wchars;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
strcpy for unicode strings. returns length (in num of wide chars)
|
||||||
|
********************************************************************/
|
||||||
|
int unistrcpy(char *dst, char *src)
|
||||||
|
{
|
||||||
|
int num_wchars = 0;
|
||||||
|
|
||||||
|
while (*src)
|
||||||
|
{
|
||||||
|
*dst++ = *src++;
|
||||||
|
*dst++ = *src++;
|
||||||
|
num_wchars++;
|
||||||
|
}
|
||||||
|
*dst++ = 0;
|
||||||
|
*dst++ = 0;
|
||||||
|
|
||||||
|
return num_wchars;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
safe string copy into a fstring
|
safe string copy into a fstring
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
@ -4231,3 +4305,42 @@ void pstrcpy(char *dest, char *src)
|
|||||||
strlen(src)));
|
strlen(src)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
align a pointer to a multiple of 4 bytes
|
||||||
|
********************************************************************/
|
||||||
|
char *align4(char *q, char *base)
|
||||||
|
{
|
||||||
|
if ((q - base) & 3)
|
||||||
|
{
|
||||||
|
q += 4 - ((q - base) & 3);
|
||||||
|
}
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
align a pointer to a multiple of 2 bytes
|
||||||
|
********************************************************************/
|
||||||
|
char *align2(char *q, char *base)
|
||||||
|
{
|
||||||
|
if ((q - base) & 1)
|
||||||
|
{
|
||||||
|
q++;
|
||||||
|
}
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
align a pointer to a multiple of align_offset bytes. looks like it
|
||||||
|
will work for offsets of 0, 2 and 4...
|
||||||
|
********************************************************************/
|
||||||
|
char *align_offset(char *q, char *base, int align_offset)
|
||||||
|
{
|
||||||
|
if (align_offset != 0 && ((q - base) & (align_offset-1)))
|
||||||
|
{
|
||||||
|
q += align_offset - ((q - base) & (align_offset));
|
||||||
|
}
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -354,21 +354,32 @@ char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align)
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
reads or writes an RPC_HDR structure.
|
||||||
|
********************************************************************/
|
||||||
|
char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align)
|
||||||
|
{
|
||||||
|
if (rpc == NULL) return NULL;
|
||||||
|
|
||||||
|
/* reserved should be zero: enforce it */
|
||||||
|
rpc->reserved = 0;
|
||||||
|
|
||||||
|
RW_CVAL(io, q, rpc->major, 0); q++;
|
||||||
|
RW_CVAL(io, q, rpc->minor, 0); q++;
|
||||||
|
RW_CVAL(io, q, rpc->pkt_type, 0); q++;
|
||||||
|
RW_CVAL(io, q, rpc->frag, 0); q++;
|
||||||
|
RW_IVAL(io, q, rpc->pack_type, 0); q += 4;
|
||||||
|
RW_SVAL(io, q, rpc->frag_len, 0); q += 2;
|
||||||
|
RW_SVAL(io, q, rpc->auth_len, 0); q += 2;
|
||||||
|
RW_IVAL(io, q, rpc->call_id, 0); q += 4;
|
||||||
|
RW_SVAL(io, q, rpc->alloc_hint, 0); q += 2;
|
||||||
|
RW_CVAL(io, q, rpc->context_id, 0); q++;
|
||||||
|
RW_CVAL(io, q, rpc->reserved, 0); q++;
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*******************************************************************
|
|
||||||
reads or writes a structure.
|
|
||||||
********************************************************************/
|
|
||||||
char* smb_io_(BOOL io, *, char *q, char *base, int align)
|
|
||||||
{
|
|
||||||
if (== NULL) return NULL;
|
|
||||||
|
|
||||||
q = align_offset(q, base, align);
|
|
||||||
|
|
||||||
RW_IVAL(io, q, , 0); q += 4;
|
|
||||||
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
reads or writes a structure.
|
reads or writes a structure.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user