1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-03 04:23:50 +03:00

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
This commit is contained in:
Jeremy Allison
2010-10-27 14:17:46 -07:00
parent 6486733049
commit c6d7e6ad08

View File

@@ -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;
}