]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: Align change notify replies on 4-byte boundary
authorChere Zhou <chere.zhou@isilon.com>
Tue, 6 Jul 2010 00:18:35 +0000 (17:18 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 21 Sep 2010 08:27:41 +0000 (10:27 +0200)
MS-CIFS section 2.2.7.4.2 states this is mandatory.  WinXP clients
don't seem to care, but a Win7 client will send an immediate Close()
to the directory handle when receiving an incorrectly aligned
change notify response.

Fix bug #7662 (Change notify replies must be aligned on 4-byte boundary for
Win7.)

source3/smbd/notify.c

index 0c75769594f6e350ebe7930df0b9edb3d35d684d..a53f3fb409770c0f73e6ec5705e676d8d8b9287d 100644 (file)
@@ -76,6 +76,7 @@ static bool notify_marshall_changes(int num_changes,
        for (i=0; i<num_changes; i++) {
                struct notify_change *c;
                size_t namelen;
+               int    rem = 0;
                uint32 u32_tmp; /* Temp arg to prs_uint32 to avoid
                                 * signed/unsigned issues */
 
@@ -101,6 +102,11 @@ static bool notify_marshall_changes(int num_changes,
                 */
 
                u32_tmp = (i == num_changes-1) ? 0 : namelen + 12;
+
+               /* Align on 4-byte boundary according to MS-CIFS 2.2.7.4.2 */
+               if ((rem = u32_tmp % 4 ) != 0)
+                       u32_tmp += 4 - rem;
+
                if (!prs_uint32("offset", ps, 1, &u32_tmp)) goto fail;
 
                u32_tmp = c->action;
@@ -116,6 +122,10 @@ static bool notify_marshall_changes(int num_changes,
                 */
                prs_set_offset(ps, prs_offset(ps)-2);
 
+               if (rem != 0) {
+                       if (!prs_align_custom(ps, 4)) goto fail;
+               }
+
                TALLOC_FREE(uni_name.buffer);
 
                if (prs_offset(ps) > max_offset) {