summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-10-27 14:17:46 -0700
committerJeremy Allison <jra@samba.org>2010-10-27 22:02:11 +0000
commitc6d7e6ad08a94709264d05b9cc8f266f07bc6851 (patch)
tree1a31220bbf5ff07f0015f09be90bbc399b75e0b4 /source3/libsmb
parent64867330493c676cfe6a34ea462be45c638966ee (diff)
downloadsamba-c6d7e6ad08a94709264d05b9cc8f266f07bc6851.tar.gz
samba-c6d7e6ad08a94709264d05b9cc8f266f07bc6851.tar.bz2
samba-c6d7e6ad08a94709264d05b9cc8f266f07bc6851.zip
Fix for bug 7755 - SMBC_getdents_ctx() ignores struct alignment rules
Based on a fix from Sven Neumann <s.neumann@raumfeld.com>. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Wed Oct 27 22:02:11 UTC 2010 on sn-devel-104
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/libsmb_dir.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 7661ecf2f8..9398f92612 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -1050,6 +1050,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) {
@@ -1086,17 +1087,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;
}