s3: libsmbclient: Fix cli_setpathinfo_basic() to treat mode == -1 as no change.
authorJeremy Allison <jra@samba.org>
Fri, 21 Jul 2017 16:56:45 +0000 (09:56 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 25 Jul 2017 15:43:15 +0000 (17:43 +0200)
This is only called from SMBC_setatr(), so bring it into line with
the specification for that function.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/clirap.c

index dd2c30e2258be205f74f44f1f83b303d0c50634b..f897df630532186b702a49b74b171d337ff6cc6e 100644 (file)
@@ -732,8 +732,17 @@ NTSTATUS cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
         put_long_date(p, change_time);
         p += 8;
 
-        /* Add attributes */
-        SIVAL(p, 0, mode);
+       if (mode == (uint16_t)-1 || mode == FILE_ATTRIBUTE_NORMAL) {
+               /* No change. */
+               mode = 0;
+       } else if (mode == 0) {
+               /* Clear all existing attributes. */
+               mode = FILE_ATTRIBUTE_NORMAL;
+       }
+
+       /* Add attributes */
+       SIVAL(p, 0, mode);
+
         p += 4;
 
         /* Add padding */