The Samba-Bugzilla – Attachment 1185 Details for
Bug 2662
revamped directory handling code is not 64bit clean
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
use SMB_OFF_T for directory offsets
large-dir-offsets.diff (text/plain), 15.65 KB, created by
James Peach
on 2005-04-27 21:21:26 UTC
(
hide
)
Description:
use SMB_OFF_T for directory offsets
Filename:
MIME Type:
Creator:
James Peach
Created:
2005-04-27 21:21:26 UTC
Size:
15.65 KB
patch
obsolete
>Index: smbd/reply.c >=================================================================== >--- smbd/reply.c (revision 6504) >+++ smbd/reply.c (working copy) >@@ -1779,7 +1779,7 @@ > */ > > if (dir_hnd) { >- long offset = 0; >+ SMB_OFF_T offset = 0; > error = NT_STATUS_NO_SUCH_FILE; > > if (strequal(mask,"????????.???")) >@@ -3577,7 +3577,7 @@ > { > const char *dname = NULL; > BOOL ret = False; >- long offset = 0; >+ SMB_OFF_T offset = 0; > struct smb_Dir *dir_hnd = OpenDir(conn, directory); > > if(dir_hnd == NULL) >@@ -3649,7 +3649,7 @@ > struct smb_Dir *dir_hnd = OpenDir(conn, directory); > > if(dir_hnd != NULL) { >- long dirpos = TellDir(dir_hnd); >+ SMB_OFF_T dirpos = TellDir(dir_hnd); > while ((dname = ReadDirName(dir_hnd,&dirpos))) { > if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0)) > continue; >@@ -4208,7 +4208,7 @@ > dir_hnd = OpenDir(conn, directory); > > if (dir_hnd) { >- long offset = 0; >+ SMB_OFF_T offset = 0; > error = NT_STATUS_NO_SUCH_FILE; > /* Was error = NT_STATUS_OBJECT_NAME_NOT_FOUND; - gentest fix. JRA */ > >@@ -4564,7 +4564,7 @@ > dir_hnd = OpenDir(conn, directory); > > if (dir_hnd) { >- long offset = 0; >+ SMB_OFF_T offset = 0; > error = ERRbadfile; > > if (strequal(mask,"????????.???")) >Index: smbd/vfs.c >=================================================================== >--- smbd/vfs.c (revision 6504) >+++ smbd/vfs.c (working copy) >@@ -615,7 +615,7 @@ > A vfs_readdir wrapper which just returns the file name. > ********************************************************************/ > >-char *vfs_readdirname(connection_struct *conn, void *p) >+char *vfs_readdirname(connection_struct *conn, DIR *p) > { > SMB_STRUCT_DIRENT *ptr= NULL; > char *dname; >Index: smbd/vfs-wrap.c >=================================================================== >--- smbd/vfs-wrap.c (revision 6504) >+++ smbd/vfs-wrap.c (working copy) >@@ -108,16 +108,16 @@ > return result; > } > >-void vfswrap_seekdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp, long offset) >+void vfswrap_seekdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp, SMB_OFF_T offset) > { > START_PROFILE(syscall_seekdir); > sys_seekdir(dirp, offset); > END_PROFILE(syscall_seekdir); > } > >-long vfswrap_telldir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) >+SMB_OFF_T vfswrap_telldir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) > { >- long result; >+ SMB_OFF_T result; > START_PROFILE(syscall_telldir); > result = sys_telldir(dirp); > END_PROFILE(syscall_telldir); >Index: smbd/trans2.c >=================================================================== >--- smbd/trans2.c (revision 6504) >+++ smbd/trans2.c (working copy) >@@ -2000,7 +2000,7 @@ > if(*resume_name && !continue_bit) { > SMB_STRUCT_STAT st; > >- long current_pos = 0; >+ SMB_OFF_T current_pos = 0; > /* > * Remember, mangle_map is called by > * get_lanman2_dir_entry(), so the resume name >Index: smbd/notify_hash.c >=================================================================== >--- smbd/notify_hash.c (revision 6504) >+++ smbd/notify_hash.c (working copy) >@@ -45,7 +45,7 @@ > size_t remaining_len; > size_t fullname_len; > struct smb_Dir *dp; >- long offset; >+ SMB_OFF_T offset; > > ZERO_STRUCTP(data); > >Index: smbd/dir.c >=================================================================== >--- smbd/dir.c (revision 6504) >+++ smbd/dir.c (working copy) >@@ -32,13 +32,13 @@ > > struct name_cache_entry { > char *name; >- long offset; >+ SMB_OFF_T offset; > }; > > struct smb_Dir { > connection_struct *conn; > DIR *dir; >- long offset; >+ SMB_OFF_T offset; > char *dir_path; > struct name_cache_entry *name_cache; > unsigned int name_cache_index; >@@ -492,12 +492,12 @@ > return CloseDir(dptr->dir_hnd); > } > >-void dptr_SeekDir(struct dptr_struct *dptr, long offset) >+void dptr_SeekDir(struct dptr_struct *dptr, SMB_OFF_T offset) > { > SeekDir(dptr->dir_hnd, offset); > } > >-long dptr_TellDir(struct dptr_struct *dptr) >+SMB_OFF_T dptr_TellDir(struct dptr_struct *dptr) > { > return TellDir(dptr->dir_hnd); > } >@@ -506,7 +506,7 @@ > Return the next visible file name, skipping veto'd and invisible files. > ****************************************************************************/ > >-static const char *dptr_normal_ReadDirName(struct dptr_struct *dptr, long *poffset, SMB_STRUCT_STAT *pst) >+static const char *dptr_normal_ReadDirName(struct dptr_struct *dptr, SMB_OFF_T *poffset, SMB_STRUCT_STAT *pst) > { > /* Normal search for the next file. */ > const char *name; >@@ -522,7 +522,7 @@ > Return the next visible file name, skipping veto'd and invisible files. > ****************************************************************************/ > >-const char *dptr_ReadDirName(struct dptr_struct *dptr, long *poffset, SMB_STRUCT_STAT *pst) >+const char *dptr_ReadDirName(struct dptr_struct *dptr, SMB_OFF_T *poffset, SMB_STRUCT_STAT *pst) > { > pstring pathreal; > >@@ -593,7 +593,7 @@ > Search for a file by name, skipping veto'ed and not visible files. > ****************************************************************************/ > >-BOOL dptr_SearchDir(struct dptr_struct *dptr, const char *name, long *poffset, SMB_STRUCT_STAT *pst) >+BOOL dptr_SearchDir(struct dptr_struct *dptr, const char *name, SMB_OFF_T *poffset, SMB_STRUCT_STAT *pst) > { > ZERO_STRUCTP(pst); > >@@ -619,7 +619,7 @@ > { > unsigned char *buf = (unsigned char *)buf1; > struct dptr_struct *dptr = dptr_get(key, False); >- uint32 offset; >+ SMB_OFF_T offset; > if (!dptr) { > DEBUG(1,("filling null dirptr %d\n",key)); > return(False); >@@ -640,7 +640,7 @@ > { > unsigned int key = *(unsigned char *)buf; > struct dptr_struct *dptr = dptr_get(key, False); >- uint32 offset; >+ SMB_OFF_T offset; > > if (!dptr) { > DEBUG(3,("fetched null dirptr %d\n",key)); >@@ -648,7 +648,7 @@ > } > *num = key; > offset = IVAL(buf,1)&~DPTR_MASK; >- SeekDir(dptr->dir_hnd,(long)offset); >+ SeekDir(dptr->dir_hnd,offset); > DEBUG(3,("fetching dirptr %d for path %s at offset %d\n", > key,dptr_path(key),offset)); > return(dptr); >@@ -725,7 +725,7 @@ > return(False); > > while (!found) { >- long curoff = dptr_TellDir(conn->dirptr); >+ SMB_OFF_T curoff = dptr_TellDir(conn->dirptr); > dname = dptr_ReadDirName(conn->dirptr, &curoff, &sbuf); > > DEBUG(6,("readdir on dirptr 0x%lx now at offset %ld\n", >@@ -979,11 +979,6 @@ > goto fail; > } > >- dirp->name_cache = SMB_CALLOC_ARRAY(struct name_cache_entry, NAME_CACHE_SIZE); >- if (!dirp->name_cache) { >- goto fail; >- } >- > dirhandles_open++; > return dirp; > >@@ -1029,11 +1024,19 @@ > Don't check for veto or invisible files. > ********************************************************************/ > >-const char *ReadDirName(struct smb_Dir *dirp, long *poffset) >+const char *ReadDirName(struct smb_Dir *dirp, SMB_OFF_T *poffset) > { > const char *n; > connection_struct *conn = dirp->conn; > >+ if (!dirp->name_cache) { >+ dirp->name_cache = SMB_CALLOC_ARRAY(struct name_cache_entry, NAME_CACHE_SIZE); >+ if (!dirp->name_cache) { >+ errno = ENOMEM; >+ return(NULL); >+ } >+ } >+ > SeekDir(dirp, *poffset); > while ((n = vfs_readdirname(conn, dirp->dir))) { > struct name_cache_entry *e; >@@ -1053,9 +1056,10 @@ > Seek a dir. > ********************************************************************/ > >-void SeekDir(struct smb_Dir *dirp, long offset) >+void SeekDir(struct smb_Dir *dirp, SMB_OFF_T offset) > { > if (offset != dirp->offset) { >+ SMB_ASSERT(offset != -1); > SMB_VFS_SEEKDIR(dirp->conn, dirp->dir, offset); > dirp->offset = offset; > } >@@ -1065,7 +1069,7 @@ > Tell a dir position. > ********************************************************************/ > >-long TellDir(struct smb_Dir *dirp) >+SMB_OFF_T TellDir(struct smb_Dir *dirp) > { > return(dirp->offset); > } >@@ -1075,27 +1079,29 @@ > Don't check for veto or invisible files. > ********************************************************************/ > >-BOOL SearchDir(struct smb_Dir *dirp, const char *name, long *poffset) >+BOOL SearchDir(struct smb_Dir *dirp, const char *name, SMB_OFF_T *poffset) > { > int i; > const char *entry; > connection_struct *conn = dirp->conn; > >- /* Search back in the name cache. */ >- for (i = dirp->name_cache_index; i >= 0; i--) { >- struct name_cache_entry *e = &dirp->name_cache[i]; >- if (e->name && (conn->case_sensitive ? (strcmp(e->name, name) == 0) : strequal(e->name, name))) { >- *poffset = e->offset; >- SeekDir(dirp, e->offset); >- return True; >+ if (dirp->name_cache) { >+ /* Search back in the name cache. */ >+ for (i = dirp->name_cache_index; i >= 0; i--) { >+ struct name_cache_entry *e = &dirp->name_cache[i]; >+ if (e->name && (conn->case_sensitive ? (strcmp(e->name, name) == 0) : strequal(e->name, name))) { >+ *poffset = e->offset; >+ SeekDir(dirp, e->offset); >+ return True; >+ } > } >- } >- for (i = NAME_CACHE_SIZE-1; i > dirp->name_cache_index; i--) { >- struct name_cache_entry *e = &dirp->name_cache[i]; >- if (e->name && (conn->case_sensitive ? (strcmp(e->name, name) == 0) : strequal(e->name, name))) { >- *poffset = e->offset; >- SeekDir(dirp, e->offset); >- return True; >+ for (i = NAME_CACHE_SIZE-1; i > dirp->name_cache_index; i--) { >+ struct name_cache_entry *e = &dirp->name_cache[i]; >+ if (e->name && (conn->case_sensitive ? (strcmp(e->name, name) == 0) : strequal(e->name, name))) { >+ *poffset = e->offset; >+ SeekDir(dirp, e->offset); >+ return True; >+ } > } > } > >Index: smbd/filename.c >=================================================================== >--- smbd/filename.c (revision 6504) >+++ smbd/filename.c (working copy) >@@ -431,7 +431,7 @@ > struct smb_Dir *cur_dir; > const char *dname; > BOOL mangled; >- long curpos; >+ SMB_OFF_T curpos; > > mangled = mangle_is_mangled(name); > >Index: nsswitch/winbind_client.h >=================================================================== >--- nsswitch/winbind_client.h (revision 6504) >+++ nsswitch/winbind_client.h (working copy) >@@ -1,3 +1,12 @@ >+ >+#ifndef CONST_DISCARD >+#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) >+#endif >+ >+#ifndef CONST_ADD >+#define CONST_ADD(type, ptr) ((type) ((const void *) (ptr))) >+#endif >+ > #include "winbind_nss_config.h" > #include "winbindd_nss.h" > >Index: lib/system.c >=================================================================== >--- lib/system.c (revision 6504) >+++ lib/system.c (working copy) >@@ -391,7 +391,7 @@ > A seekdir wrapper that will deal with 64 bit filesizes. > ********************************************************************/ > >-void sys_seekdir(DIR *dirp, long offset) >+void sys_seekdir(DIR *dirp, SMB_OFF_T offset) > { > #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_SEEKDIR64) > seekdir64(dirp, offset); >@@ -404,12 +404,12 @@ > A telldir wrapper that will deal with 64 bit filesizes. > ********************************************************************/ > >-long sys_telldir(DIR *dirp) >+SMB_OFF_T sys_telldir(DIR *dirp) > { > #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_TELLDIR64) >- return (long)telldir64(dirp); >+ return telldir64(dirp); > #else >- return (long)telldir(dirp); >+ return telldir(dirp); > #endif > } > >Index: modules/vfs_full_audit.c >=================================================================== >--- modules/vfs_full_audit.c (revision 6504) >+++ modules/vfs_full_audit.c (working copy) >@@ -91,8 +91,8 @@ > static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, > connection_struct *conn, DIR *dirp); > static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn, >- DIR *dirp, long offset); >-static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, >+ DIR *dirp, SMB_OFF_T offset); >+static SMB_OFF_T smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, > DIR *dirp); > static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn, > DIR *dirp); >@@ -835,7 +835,7 @@ > } > > static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn, >- DIR *dirp, long offset) >+ DIR *dirp, SMB_OFF_T offset) > { > SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset); > >@@ -843,10 +843,10 @@ > return; > } > >-static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, >+static SMB_OFF_T smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, > DIR *dirp) > { >- long result; >+ SMB_OFF_T result; > > result = SMB_VFS_NEXT_TELLDIR(handle, conn, dirp); > >Index: include/vfs.h >=================================================================== >--- include/vfs.h (revision 6504) >+++ include/vfs.h (working copy) >@@ -56,7 +56,8 @@ > /* Changed to version 9 to include the get_shadow_data call. --metze */ > /* Changed to version 10 to include pread/pwrite calls. */ > /* Changed to version 11 to include seekdir/telldir/rewinddir calls. JRA */ >-#define SMB_VFS_INTERFACE_VERSION 11 >+/* Changed to version 12 to change seekdir/telldir type to SMB_OFF_T. -- jpeach * */ >+#define SMB_VFS_INTERFACE_VERSION 12 > > > /* to bug old modules witch are trying to compile with the old functions */ >@@ -214,8 +215,8 @@ > > DIR *(*opendir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname); > SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); >- void (*seekdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp, long offset); >- long (*telldir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); >+ void (*seekdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp, SMB_OFF_T offset); >+ SMB_OFF_T (*telldir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); > void (*rewind_dir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); > int (*mkdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, mode_t mode); > int (*rmdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path); >Index: configure.in >=================================================================== >--- configure.in (revision 6504) >+++ configure.in (working copy) >@@ -534,6 +534,16 @@ > # > *irix*) > AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility]) >+ # Try to make sure _SGI_SOURCE is defined. This is an attempt >+ # to introduce sanity to a world of standards. >+ case "$CPPFLAGS" in >+ *SGI_SOURCE*) >+ ;; >+ *) >+ CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE" >+ ;; >+ esac >+ > ;; > *freebsd*|*DragonFly*) > AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD]) >Index: script/mkbuildoptions.awk >=================================================================== >--- script/mkbuildoptions.awk (revision 6504) >+++ script/mkbuildoptions.awk (working copy) >@@ -245,11 +245,16 @@ > print " output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));"; > print " output(screen, \" sizeof(int): %lu\\n\",(unsigned long)sizeof(int));"; > print " output(screen, \" sizeof(long): %lu\\n\",(unsigned long)sizeof(long));"; >+ print "#if HAVE_LONGLONG"; >+ print " output(screen, \" sizeof(long long):%lu\\n\",(unsigned long)sizeof(long long));"; >+ print "#endif"; > print " output(screen, \" sizeof(uint8): %lu\\n\",(unsigned long)sizeof(uint8));"; > print " output(screen, \" sizeof(uint16): %lu\\n\",(unsigned long)sizeof(uint16));"; > print " output(screen, \" sizeof(uint32): %lu\\n\",(unsigned long)sizeof(uint32));"; > print " output(screen, \" sizeof(short): %lu\\n\",(unsigned long)sizeof(short));"; > print " output(screen, \" sizeof(void*): %lu\\n\",(unsigned long)sizeof(void*));"; >+ print " output(screen, \" sizeof(off_t): %lu\\n\",(unsigned long)sizeof(off_t));"; >+ print " output(screen, \" sizeof(size_t): %lu\\n\",(unsigned long)sizeof(size_t));"; > > ################################################## > # add code to give information about modules
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 2662
:
1185
|
1196
|
9586
|
9587
|
9596
|
9597