From f6be38cae223f1ad3f4ecc5b81d14c44d92f58ba Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Apr 2000 19:44:54 +0000 Subject: include/byteorder.h: ALIGN4/ALIGN2 macros. include/includes.h: Added SMB_BIG_UINT_BITS. lib/util.c: Removed align2/align4 - use macros. libsmb/namequery.c: Use ALIGN2. locking/locking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. Needed to move to hiding POSIX locks at a lower layer. nmbd/nmbd_processlogon.c: Use ALIGN2/ALIGN4 macros. smbd/blocking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. smbd/reply.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T. Jeremy. (This used to be commit 491eea8a20bf80d426625479326211dc975857a6) --- source3/include/byteorder.h | 4 +- source3/include/includes.h | 2 + source3/include/proto.h | 12 ++- source3/lib/util.c | 25 ------- source3/libsmb/namequery.c | 2 +- source3/locking/locking.c | 6 +- source3/nmbd/nmbd_processlogon.c | 6 +- source3/smbd/blocking.c | 12 +-- source3/smbd/reply.c | 158 +++++++++++++-------------------------- 9 files changed, 75 insertions(+), 152 deletions(-) (limited to 'source3') diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h index b376a8964c..f050e5d6cf 100644 --- a/source3/include/byteorder.h +++ b/source3/include/byteorder.h @@ -263,7 +263,7 @@ it also defines lots of intermediate macros, just ignore those :-) tab_depth(depth), base, string, outbuf)); } /* Alignment macros. */ -#define ALIGN4(p,base) ((4 - (PTR_DIFF((q), (base)) % 4)) & ~3) -#define ALIGN2(p,base) ((2 - (PTR_DIFF((q), (base)) % 2)) & ~1) +#define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) % 4)) & ~3)) +#define ALIGN2(p,base) ((p) + ((2 - (PTR_DIFF((p), (base)) % 2)) & ~1)) #endif /* _BYTEORDER_H */ diff --git a/source3/include/includes.h b/source3/include/includes.h index f77e1323d7..5bc4797cb4 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -600,6 +600,8 @@ union semun_hack { #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0)) #endif +#define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8) + #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif diff --git a/source3/include/proto.h b/source3/include/proto.h index 0fafa89e82..f6d387d19e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -331,8 +331,6 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); BOOL is_myname(char *s); void set_remote_arch(enum remote_arch_types type); enum remote_arch_types get_remote_arch(void); -char *align2(char *q, char *base); -char *align4(char *q, char *base); void out_ascii(FILE *f, unsigned char *buf,int len); void out_data(FILE *f,char *buf1,int len, int per_line); void print_asc(int level, unsigned char *buf,int len); @@ -780,13 +778,13 @@ int brl_forall(BRLOCK_FN(fn)); void locking_close_file(files_struct *fsp); BOOL is_locked(files_struct *fsp,connection_struct *conn, - SMB_OFF_T count,SMB_OFF_T offset, + SMB_BIG_UINT count,SMB_BIG_UINT offset, enum brl_type lock_type); BOOL do_lock(files_struct *fsp,connection_struct *conn, - SMB_OFF_T count,SMB_OFF_T offset,enum brl_type lock_type, + SMB_BIG_UINT count,SMB_BIG_UINT offset,enum brl_type lock_type, int *eclass,uint32 *ecode); BOOL do_unlock(files_struct *fsp,connection_struct *conn, - SMB_OFF_T count,SMB_OFF_T offset, + SMB_BIG_UINT count,SMB_BIG_UINT offset, int *eclass,uint32 *ecode); BOOL locking_init(int read_only); BOOL locking_end(void); @@ -3196,8 +3194,8 @@ int rename_internals(connection_struct *conn, int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize); int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize); int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize); -SMB_OFF_T get_lock_count( char *data, int data_offset, BOOL large_file_format, BOOL *err); -SMB_OFF_T get_lock_offset( char *data, int data_offset, BOOL large_file_format, BOOL *err); +SMB_BIG_UINT get_lock_count( char *data, int data_offset, BOOL large_file_format); +SMB_BIG_UINT get_lock_offset( char *data, int data_offset, BOOL large_file_format, BOOL *err); int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize); int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize); int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size, int dum_buffsize); diff --git a/source3/lib/util.c b/source3/lib/util.c index fdd2b98c56..8c5ea1d208 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2602,31 +2602,6 @@ enum remote_arch_types get_remote_arch(void) } -/******************************************************************* -align a pointer to a multiple of 2 bytes -********************************************************************/ -char *align2(char *q, char *base) -{ - if (PTR_DIFF(q, base) & 1) - { - q++; - } - return q; -} - -/******************************************************************* - align a pointer to a multiple of 4 bytes. - ********************************************************************/ -char *align4(char *q, char *base) -{ - int mod = PTR_DIFF(q, base) & 3; - if (mod != 0) - { - q += 4-mod; - } - return q; -} - void out_ascii(FILE *f, unsigned char *buf,int len) { int i; diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 290a91f7b5..500a2ff94f 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -758,7 +758,7 @@ BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pd slprintf(bufp, sizeof(fstring), "\\MAILSLOT\\NET\\GETDC%d", dgm_id); mailslot_name = bufp; bufp += (strlen(bufp) + 1); - bufp = align2(bufp, buffer); + bufp = ALIGN2(bufp, buffer); bufp += dos_PutUniCode(bufp, srcname, sizeof(buffer) - (bufp - buffer) - 1, True); SIVAL(bufp,0,1); SSVAL(bufp,4,0xFFFF); diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 45d414daf1..1bb0a3b59c 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -57,7 +57,7 @@ void locking_close_file(files_struct *fsp) Utility function called to see if a file region is locked. ****************************************************************************/ BOOL is_locked(files_struct *fsp,connection_struct *conn, - SMB_OFF_T count,SMB_OFF_T offset, + SMB_BIG_UINT count,SMB_BIG_UINT offset, enum brl_type lock_type) { int snum = SNUM(conn); @@ -78,7 +78,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn, Utility function called by locking requests. ****************************************************************************/ BOOL do_lock(files_struct *fsp,connection_struct *conn, - SMB_OFF_T count,SMB_OFF_T offset,enum brl_type lock_type, + SMB_BIG_UINT count,SMB_BIG_UINT offset,enum brl_type lock_type, int *eclass,uint32 *ecode) { BOOL ok = False; @@ -115,7 +115,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn, Utility function called by unlocking requests. ****************************************************************************/ BOOL do_unlock(files_struct *fsp,connection_struct *conn, - SMB_OFF_T count,SMB_OFF_T offset, + SMB_BIG_UINT count,SMB_BIG_UINT offset, int *eclass,uint32 *ecode) { BOOL ok = False; diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index 76a9aea952..47467f132d 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -116,7 +116,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); getdc = skip_string(machine,1); q = skip_string(getdc,1); - q = align2(q, buf); + q = ALIGN2(q, buf); /* at this point we can work out if this is a W9X or NT style request. Experiments show that the difference is wether the @@ -160,7 +160,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); /* PDC and domain name */ if (!short_request) /* Make a full reply */ { - q = align2(q, buf); + q = ALIGN2(q, buf); q += dos_PutUniCode(q, my_name, sizeof(pstring), True); /* PDC name */ q += dos_PutUniCode(q, global_myworkgroup,sizeof(pstring), True); /* Domain name*/ @@ -207,7 +207,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", if (domainsidsize != 0) { q += domainsidsize; - q = align4(q, buf); + q = ALIGN4(q, buf); } if (len - PTR_DIFF(q, buf) > 8) { /* with NT5 clients we can sometimes diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index ea8d2fd053..ddf7de3f5b 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -193,7 +193,7 @@ static void reply_lockingX_error(blocking_lock_record *blr, int eclass, int32 ec files_struct *fsp = blr->fsp; connection_struct *conn = conn_find(SVAL(inbuf,smb_tid)); uint16 num_ulocks = SVAL(inbuf,smb_vwv6); - SMB_OFF_T count = (SMB_OFF_T) 0, offset = (SMB_OFF_T) 0; + SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT) 0; unsigned char locktype = CVAL(inbuf,smb_vwv3); BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES); char *data; @@ -217,7 +217,7 @@ static void reply_lockingX_error(blocking_lock_record *blr, int eclass, int32 ec uint32 dummy2; BOOL err; - count = get_lock_count( data, i, large_file_format, &err); + count = get_lock_count( data, i, large_file_format); offset = get_lock_offset( data, i, large_file_format, &err); /* @@ -278,7 +278,7 @@ static BOOL process_lockread(blocking_lock_record *blr) numtoread = MIN(BUFFER_SIZE-outsize,numtoread); data = smb_buf(outbuf) + 3; - if(!do_lock( fsp, conn, numtoread, startpos, READ_LOCK, &eclass, &ecode)) { + if(!do_lock( fsp, conn, (SMB_BIG_UINT)numtoread, (SMB_BIG_UINT)startpos, READ_LOCK, &eclass, &ecode)) { if((errno != EACCES) && (errno != EAGAIN)) { /* * We have other than a "can't get lock" POSIX @@ -341,7 +341,7 @@ static BOOL process_lock(blocking_lock_record *blr) offset = IVAL(inbuf,smb_vwv3); errno = 0; - if (!do_lock(fsp, conn, count, offset, WRITE_LOCK, &eclass, &ecode)) { + if (!do_lock(fsp, conn, (SMB_BIG_UINT)count, (SMB_BIG_UINT)offset, WRITE_LOCK, &eclass, &ecode)) { if((errno != EACCES) && (errno != EAGAIN)) { /* @@ -389,7 +389,7 @@ static BOOL process_lockingX(blocking_lock_record *blr) connection_struct *conn = conn_find(SVAL(inbuf,smb_tid)); uint16 num_ulocks = SVAL(inbuf,smb_vwv6); uint16 num_locks = SVAL(inbuf,smb_vwv7); - SMB_OFF_T count = 0, offset = 0; + SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT)0; BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES); char *data; int eclass=0; @@ -405,7 +405,7 @@ static BOOL process_lockingX(blocking_lock_record *blr) for(; blr->lock_num < num_locks; blr->lock_num++) { BOOL err; - count = get_lock_count( data, blr->lock_num, large_file_format, &err); + count = get_lock_count( data, blr->lock_num, large_file_format); offset = get_lock_offset( data, blr->lock_num, large_file_format, &err); /* diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 3ada28364b..96149acaa1 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2108,7 +2108,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s maxcount = MIN(65535,maxcount); maxcount = MAX(mincount,maxcount); - if (!is_locked(fsp,conn,maxcount,startpos, READ_LOCK)) + if (!is_locked(fsp,conn,(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) { SMB_OFF_T size = fsp->size; SMB_OFF_T sizeneeded = startpos + maxcount; @@ -2206,7 +2206,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length * for a write lock. JRA. */ - if(!do_lock( fsp, conn, numtoread, startpos, WRITE_LOCK, &eclass, &ecode)) { + if(!do_lock( fsp, conn, (SMB_BIG_UINT)numtoread, (SMB_BIG_UINT)startpos, WRITE_LOCK, &eclass, &ecode)) { if((ecode == ERRlock) && lp_blocking_locks(SNUM(conn))) { /* * A blocking lock was requested. Package up @@ -2260,7 +2260,7 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int size, int numtoread = MIN(BUFFER_SIZE-outsize,numtoread); data = smb_buf(outbuf) + 3; - if (is_locked(fsp,conn,numtoread,startpos, READ_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)numtoread,(SMB_BIG_UINT)startpos, READ_LOCK)) return(ERROR(ERRDOS,ERRlock)); if (numtoread > 0) @@ -2328,7 +2328,7 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt } - if (is_locked(fsp,conn,smb_maxcnt,startpos, READ_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)smb_maxcnt,(SMB_BIG_UINT)startpos, READ_LOCK)) return(ERROR(ERRDOS,ERRlock)); nread = read_file(fsp,data,startpos,smb_maxcnt); @@ -2383,7 +2383,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size, CVAL(inbuf,smb_com) = SMBwritec; CVAL(outbuf,smb_com) = SMBwritec; - if (is_locked(fsp,conn,tcount,startpos, WRITE_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos, WRITE_LOCK)) return(ERROR(ERRDOS,ERRlock)); if (numtowrite>0) @@ -2471,7 +2471,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz startpos = IVAL(inbuf,smb_vwv2); data = smb_buf(inbuf) + 3; - if (is_locked(fsp,conn,numtowrite,startpos, WRITE_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) return(ERROR(ERRDOS,ERRlock)); /* The special X/Open SMB protocol handling of @@ -2488,7 +2488,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int siz if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) return(UNIXERROR(ERRDOS,ERRnoaccess)); - if(!do_unlock(fsp, conn, numtowrite, startpos, &eclass, &ecode)) + if(!do_unlock(fsp, conn, (SMB_BIG_UINT)numtowrite, (SMB_BIG_UINT)startpos, &eclass, &ecode)) return(ERROR(eclass,ecode)); outsize = set_message(outbuf,1,0,True); @@ -2525,7 +2525,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d startpos = IVAL(inbuf,smb_vwv2); data = smb_buf(inbuf) + 3; - if (is_locked(fsp,conn,numtowrite,startpos, WRITE_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) return(ERROR(ERRDOS,ERRlock)); /* X/Open SMB protocol says that if smb_vwv1 is @@ -2604,7 +2604,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng #endif /* LARGE_SMB_OFF_T */ } - if (is_locked(fsp,conn,numtowrite,startpos, WRITE_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) return(ERROR(ERRDOS,ERRlock)); /* X/Open SMB protocol says that, unlike SMBwrite @@ -2858,7 +2858,7 @@ int reply_writeclose(connection_struct *conn, mtime = make_unix_date3(inbuf+smb_vwv4); data = smb_buf(inbuf) + 1; - if (is_locked(fsp,conn,numtowrite,startpos, WRITE_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK)) return(ERROR(ERRDOS,ERRlock)); nwritten = write_file(fsp,data,startpos,numtowrite); @@ -2893,7 +2893,7 @@ int reply_lock(connection_struct *conn, char *inbuf,char *outbuf, int length, int dum_buffsize) { int outsize = set_message(outbuf,0,0,True); - SMB_OFF_T count,offset; + SMB_BIG_UINT count,offset; int eclass; uint32 ecode; files_struct *fsp = file_fsp(inbuf,smb_vwv0); @@ -2901,8 +2901,8 @@ int reply_lock(connection_struct *conn, CHECK_FSP(fsp,conn); CHECK_ERROR(fsp); - count = IVAL(inbuf,smb_vwv1); - offset = IVAL(inbuf,smb_vwv3); + count = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv1); + offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3); DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n", fsp->fd, fsp->fnum, (double)offset, (double)count)); @@ -2930,7 +2930,7 @@ int reply_lock(connection_struct *conn, int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, int dum_buffsize) { int outsize = set_message(outbuf,0,0,True); - SMB_OFF_T count,offset; + SMB_BIG_UINT count,offset; int eclass; uint32 ecode; files_struct *fsp = file_fsp(inbuf,smb_vwv0); @@ -2938,8 +2938,8 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, in CHECK_FSP(fsp,conn); CHECK_ERROR(fsp); - count = IVAL(inbuf,smb_vwv1); - offset = IVAL(inbuf,smb_vwv3); + count = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv1); + offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3); if(!do_unlock(fsp, conn, count, offset, &eclass, &ecode)) return (ERROR(eclass,ecode)); @@ -3996,27 +3996,23 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size Get a lock count, dealing with large count requests. ****************************************************************************/ -SMB_OFF_T get_lock_count( char *data, int data_offset, BOOL large_file_format, BOOL *err) +SMB_BIG_UINT get_lock_count( char *data, int data_offset, BOOL large_file_format) { - SMB_OFF_T count = 0; - - *err = False; + SMB_BIG_UINT count = 0; if(!large_file_format) { - count = (SMB_OFF_T)IVAL(data,SMB_LKLEN_OFFSET(data_offset)); + count = (SMB_BIG_UINT)IVAL(data,SMB_LKLEN_OFFSET(data_offset)); } else { -#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS) - - count = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) << 32) | - ((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset))); - -#else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */ +#if defined(HAVE_LONGLONG) + count = (((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) << 32) | + ((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset))); +#else /* HAVE_LONGLONG */ /* - * NT4.x seems to be broken in that it sends large file + * NT4.x seems to be broken in that it sends large file (64 bit) * lockingX calls even if the CAP_LARGE_FILES was *not* - * negotiated. For boxes without large file locks truncate the + * negotiated. For boxes without large unsigned ints truncate the * lock count by dropping the top 32 bits. */ @@ -4027,33 +4023,10 @@ SMB_OFF_T get_lock_count( char *data, int data_offset, BOOL large_file_format, B SIVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset),0); } - if(IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)) != 0) { - /* - * Before we error out, see if we can sensibly map the top bits - * down to the lower bits - or lose the top bits if they are all 1's. - * It seems that NT has this horrible bug where it will send 64 bit - * lock requests even if told not to. JRA. - */ - - if(IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)) == (uint32)0xFFFFFFFF) - count = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)); - else if (IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)) == (uint32)0xFFFFFFFF) - count = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)); - else { - - DEBUG(0,("get_lock_count: Error : a large file count (%x << 32 | %x) was sent and we don't \ -support large counts.\n", (unsigned int)IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset)), - (unsigned int)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)) )); - - *err = True; - return (SMB_OFF_T)-1; - } - } - else - count = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)); - -#endif /* LARGE_SMB_OFF_T */ + count = (SMB_BIG_UINT)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)); +#endif /* HAVE_LONGLONG */ } + return count; } @@ -4061,27 +4034,25 @@ support large counts.\n", (unsigned int)IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(da Get a lock offset, dealing with large offset requests. ****************************************************************************/ -SMB_OFF_T get_lock_offset( char *data, int data_offset, BOOL large_file_format, BOOL *err) +SMB_BIG_UINT get_lock_offset( char *data, int data_offset, BOOL large_file_format, BOOL *err) { - SMB_OFF_T offset = 0; + SMB_BIG_UINT offset = 0; *err = False; if(!large_file_format) { - offset = (SMB_OFF_T)IVAL(data,SMB_LKOFF_OFFSET(data_offset)); + offset = (SMB_BIG_UINT)IVAL(data,SMB_LKOFF_OFFSET(data_offset)); } else { -#if defined(LARGE_SMB_OFF_T) && !defined(HAVE_BROKEN_FCNTL64_LOCKS) - - offset = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) << 32) | - ((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset))); - -#else /* !LARGE_SMB_OFF_T || HAVE_BROKEN_FCNTL64_LOCKS */ +#if defined(HAVE_LONGLONG) + offset = (((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) << 32) | + ((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset))); +#else /* HAVE_LONGLONG */ /* - * NT4.x seems to be broken in that it sends large file + * NT4.x seems to be broken in that it sends large file (64 bit) * lockingX calls even if the CAP_LARGE_FILES was *not* - * negotiated. For boxes without large file locks mangle the + * negotiated. For boxes without large unsigned ints mangle the * lock offset by mapping the top 32 bits onto the lower 32. */ @@ -4092,7 +4063,7 @@ SMB_OFF_T get_lock_offset( char *data, int data_offset, BOOL large_file_format, if((new_low = map_lock_offset(high, low)) == 0) { *err = True; - return (SMB_OFF_T)-1; + return (SMB_BIG_UINT)-1; } DEBUG(3,("get_lock_offset: truncating lock offset (high)0x%x (low)0x%x to offset 0x%x.\n", @@ -4101,33 +4072,10 @@ SMB_OFF_T get_lock_offset( char *data, int data_offset, BOOL large_file_format, SIVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset),new_low); } - if(IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0){ - /* - * Before we error out, see if we can sensibly map the top bits - * down to the lower bits - or lose the top bits if they are all 1's. - * It seems that NT has this horrible bug where it will send 64 bit - * lock requests even if told not to. JRA. - */ - - if(IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)) == (uint32)0xFFFFFFFF) - offset = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)); - else if(IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) == (uint32)0xFFFFFFFF) - offset = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)); - else { - - DEBUG(0,("get_lock_count: Error : a large file offset (%x << 32 | %x) was sent and we don't \ -support large offsets.\n", (unsigned int)IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)), - (unsigned int)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)) )); - - *err = True; - return (SMB_OFF_T)-1; - } - } - else - offset = (SMB_OFF_T)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)); - + offset = (SMB_BIG_UINT)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)); #endif /* LARGE_SMB_OFF_T */ } + return offset; } @@ -4144,14 +4092,14 @@ int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length, #endif uint16 num_ulocks = SVAL(inbuf,smb_vwv6); uint16 num_locks = SVAL(inbuf,smb_vwv7); - SMB_OFF_T count = 0, offset = 0; + SMB_BIG_UINT count = 0, offset = 0; int32 lock_timeout = IVAL(inbuf,smb_vwv4); int i; char *data; uint32 ecode=0, dummy2; int eclass=0, dummy1; BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES); - BOOL err1, err2; + BOOL err; CHECK_FSP(fsp,conn); CHECK_ERROR(fsp); @@ -4202,13 +4150,13 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name)); /* Data now points at the beginning of the list of smb_unlkrng structs */ for(i = 0; i < (int)num_ulocks; i++) { - count = get_lock_count( data, i, large_file_format, &err1); - offset = get_lock_offset( data, i, large_file_format, &err2); + count = get_lock_count( data, i, large_file_format); + offset = get_lock_offset( data, i, large_file_format, &err); /* * There is no error code marked "stupid client bug".... :-). */ - if(err1 || err2) + if(err) return ERROR(ERRDOS,ERRnoaccess); DEBUG(10,("reply_lockingX: unlock start=%.0f, len=%.0f for file %s\n", @@ -4228,13 +4176,13 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name)); of smb_lkrng structs */ for(i = 0; i < (int)num_locks; i++) { - count = get_lock_count( data, i, large_file_format, &err1); - offset = get_lock_offset( data, i, large_file_format, &err2); + count = get_lock_count( data, i, large_file_format); + offset = get_lock_offset( data, i, large_file_format, &err); /* * There is no error code marked "stupid client bug".... :-). */ - if(err1 || err2) + if(err) return ERROR(ERRDOS,ERRnoaccess); DEBUG(10,("reply_lockingX: lock start=%.0f, len=%.0f for file %s\n", @@ -4264,13 +4212,13 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name)); * will delete it (and we shouldn't) ..... */ for(i--; i >= 0; i--) { - count = get_lock_count( data, i, large_file_format, &err1); - offset = get_lock_offset( data, i, large_file_format, &err2); + count = get_lock_count( data, i, large_file_format); + offset = get_lock_offset( data, i, large_file_format, &err); /* * There is no error code marked "stupid client bug".... :-). */ - if(err1 || err2) + if(err) return ERROR(ERRDOS,ERRnoaccess); do_unlock(fsp,conn,count,offset,&dummy1,&dummy2); @@ -4325,7 +4273,7 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length, tcount = maxcount; total_read = 0; - if (is_locked(fsp,conn,maxcount,startpos, READ_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)maxcount,(SMB_BIG_UINT)startpos, READ_LOCK)) return(ERROR(ERRDOS,ERRlock)); do @@ -4387,7 +4335,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size, not an SMBwritebmpx - set this up now so we don't forget */ CVAL(outbuf,smb_com) = SMBwritec; - if (is_locked(fsp,conn,tcount,startpos,WRITE_LOCK)) + if (is_locked(fsp,conn,(SMB_BIG_UINT)tcount,(SMB_BIG_UINT)startpos,WRITE_LOCK)) return(ERROR(ERRDOS,ERRlock)); nwritten = write_file(fsp,data,startpos,numtowrite); -- cgit