s3: libsmb: Widen the internal client smb1.pid to 32-bits as is used on the wire...
authorJeremy Allison <jra@samba.org>
Fri, 10 Jun 2016 23:51:11 +0000 (16:51 -0700)
committerAlexander Bokovoy <ab@samba.org>
Sat, 18 Jun 2016 13:32:17 +0000 (15:32 +0200)
Note: This has *NO* effect on the lock context code, as on the
wire for all SMB1 locking requests, the pid used as the lock
context is already truncated down to 16-bits - the field is only
16-bits wide.

This allows the cli_XXX() calls to correctly set pidlow AND pidhigh
in SMB1 requests put on the wire by the libcli/smb/smb1*.c code.

Note that currently the smbd server doesn't correctly return
pidhigh yet - a fix (and tests) for that will follow.

As pidhigh is not checked in any client code (mid is used
to differentiate different requests) this has no effect
other than a correctness fix.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/include/client.h
source3/libsmb/clientgen.c
source3/libsmb/proto.h

index 0024c04a5ad35386615235edc87a634d615deb16..43ec39bb5a7729296f9a517edc9a0cdfa5c0a909 100644 (file)
@@ -91,7 +91,7 @@ struct cli_state {
        const char *remote_realm;
 
        struct {
-               uint16_t pid;
+               uint32_t pid;
                uint16_t vc_num;
                struct smbXcli_session *session;
                struct smbXcli_tcon *tcon;
index cfb3b162358ef3da6d82ebf7c0eeb1f3f1b71bb7..bf31bb17a5705948c45bc50904f7bee8dcb9ecc8 100644 (file)
@@ -225,7 +225,7 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
                goto error;
        }
 
-       cli->smb1.pid = (uint16_t)getpid();
+       cli->smb1.pid = (uint32_t)getpid();
        cli->smb1.vc_num = cli->smb1.pid;
        cli->smb1.tcon = smbXcli_tcon_create(cli);
        if (cli->smb1.tcon == NULL) {
@@ -327,14 +327,14 @@ uint16_t cli_state_get_vc_num(struct cli_state *cli)
  Set the PID to use for smb messages. Return the old pid.
 ****************************************************************************/
 
-uint16_t cli_setpid(struct cli_state *cli, uint16_t pid)
+uint32_t cli_setpid(struct cli_state *cli, uint32_t pid)
 {
-       uint16_t ret = cli->smb1.pid;
+       uint32_t ret = cli->smb1.pid;
        cli->smb1.pid = pid;
        return ret;
 }
 
-uint16_t cli_getpid(struct cli_state *cli)
+uint32_t cli_getpid(struct cli_state *cli)
 {
        return cli->smb1.pid;
 }
index 1e358f7e3d5913571a6c8e3df9b4230349c77c2a..c5e74c932eda669c52385e61926671ac51b65768 100644 (file)
@@ -172,8 +172,8 @@ void cli_nt_pipes_close(struct cli_state *cli);
 void cli_shutdown(struct cli_state *cli);
 const char *cli_state_remote_realm(struct cli_state *cli);
 uint16_t cli_state_get_vc_num(struct cli_state *cli);
-uint16_t cli_setpid(struct cli_state *cli, uint16_t pid);
-uint16_t cli_getpid(struct cli_state *cli);
+uint32_t cli_setpid(struct cli_state *cli, uint32_t pid);
+uint32_t cli_getpid(struct cli_state *cli);
 bool cli_state_has_tcon(struct cli_state *cli);
 uint16_t cli_state_get_tid(struct cli_state *cli);
 uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);