[SCM] Samba Shared Repository - branch v3-6-test updated

Jeremy Allison jra at samba.org
Wed Oct 27 15:35:05 MDT 2010


The branch, v3-6-test has been updated
       via  d7ea0f9 Fix for bug 7755 - SMBC_getdents_ctx() ignores struct alignment rules
      from  601c003 Fix bug 7754 - samba uses index(), marked as legacy. (cherry picked from commit be22adc642270eaeff10d969357e3fa13667d176)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit d7ea0f9e6763d416cf1dcca0fb67cf66d1c63ad0
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Oct 27 14:17:46 2010 -0700

    Fix for bug 7755 - SMBC_getdents_ctx() ignores struct alignment rules
    
    Based on a fix from Sven Neumann <s.neumann at raumfeld.com>.
    (cherry picked from commit b3777da0a2396f1dabac02a2e2702dafe50e4958)

-----------------------------------------------------------------------

Summary of changes:
 source3/libsmb/libsmb_dir.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index d809219..e1d9bfd 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -1049,6 +1049,7 @@ SMBC_getdents_ctx(SMBCCTX *context,
 
 	while ((dirlist = dir->dir_next)) {
 		struct smbc_dirent *dirent;
+		struct smbc_dirent *currentEntry = (struct smbc_dirent *)ndir;
 
 		if (!dirlist->dirent) {
 
@@ -1085,17 +1086,23 @@ SMBC_getdents_ctx(SMBCCTX *context,
 
 		}
 
-		memcpy(ndir, dirent, reqd); /* Copy the data in ... */
+		memcpy(currentEntry, dirent, reqd); /* Copy the data in ... */
 
-		((struct smbc_dirent *)ndir)->comment =
-			(char *)(&((struct smbc_dirent *)ndir)->name +
-                                 dirent->namelen +
-                                 1);
+		currentEntry->comment = &currentEntry->name[0] +
+						dirent->namelen + 1;
 
 		ndir += reqd;
-
 		rem -= reqd;
 
+		/* Try and align the struct for the next entry
+		   on a valid pointer boundary by appending zeros */
+		while((rem > 0) && ((unsigned long long)ndir & (sizeof(void*) - 1))) {
+			*ndir = '\0';
+			rem--;
+			ndir++;
+			currentEntry->dirlen++;
+		}
+
 		dir->dir_next = dirlist = dirlist -> next;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list