summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-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;
}