smbclient: Align integer types
authorVolker Lendecke <vl@samba.org>
Fri, 5 Jun 2020 12:04:08 +0000 (14:04 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 10 Jun 2020 22:20:46 +0000 (22:20 +0000)
gcc complained that the if-condition compared unsigned rb_size with a
signed value. Somehow through the arithmetic the uint16_t's got
promoted to integer.

Also, avoid some printf casts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/client/client.c

index db1be9c0194b7dc6bbbbe13db8e3c5d9658845d6..c7ad339fa234ef39983af9e2d765734abbfbbd1b 100644 (file)
@@ -3765,8 +3765,9 @@ static int cmd_getfacl(void)
        char *retbuf = NULL;
        size_t rb_size = 0;
        SMB_STRUCT_STAT sbuf;
-       uint16_t num_file_acls = 0;
-       uint16_t num_dir_acls = 0;
+       size_t num_file_acls = 0;
+       size_t num_dir_acls = 0;
+       size_t expected_buflen;
        uint16_t i;
        NTSTATUS status;
 
@@ -3835,11 +3836,21 @@ static int cmd_getfacl(void)
 
        num_file_acls = SVAL(retbuf,2);
        num_dir_acls = SVAL(retbuf,4);
-       if (rb_size != SMB_POSIX_ACL_HEADER_SIZE + SMB_POSIX_ACL_ENTRY_SIZE*(num_file_acls+num_dir_acls)) {
-               d_printf("getfacl file %s, incorrect POSIX acl buffer size (should be %u, was %u).\n",
-                       src,
-                       (unsigned int)(SMB_POSIX_ACL_HEADER_SIZE + SMB_POSIX_ACL_ENTRY_SIZE*(num_file_acls+num_dir_acls)),
-                       (unsigned int)rb_size);
+
+       /*
+        * No overflow check, num_*_acls comes from a 16-bit value,
+        * and we expect expected_buflen (size_t) to be of at least 32
+        * bit.
+        */
+       expected_buflen = SMB_POSIX_ACL_HEADER_SIZE +
+               SMB_POSIX_ACL_ENTRY_SIZE*(num_file_acls+num_dir_acls);
+
+       if (rb_size != expected_buflen) {
+               d_printf("getfacl file %s, incorrect POSIX acl buffer size "
+                        "(should be %zu, was %zu).\n",
+                        src,
+                        expected_buflen,
+                        rb_size);
                return 1;
        }