s3:smbd: let srvstr_pull_req_talloc() take 'const uint8_t *src'
authorStefan Metzmacher <metze@samba.org>
Wed, 26 Feb 2014 19:16:26 +0000 (20:16 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 2 Apr 2014 07:03:43 +0000 (09:03 +0200)
This is the correct thing to do the smb request buffer contains
just bytes (uint8_t).

It also avoids strange casting in the callers.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/message.c
source3/smbd/proto.h
source3/smbd/reply.c
source3/smbd/sesssetup.c

index 3d91f1408db7b3e3e0f9ca0d8b1ae57e8550e65c..0dca2d89c22f15054533fad6ee6eef16fa09e4fb 100644 (file)
@@ -145,8 +145,8 @@ void reply_sends(struct smb_request *req)
 {
        struct msg_state *state;
        int len;
-       const char *msg;
-       const char *p;
+       const uint8_t *msg;
+       const uint8_t *p;
 
        START_PROFILE(SMBsends);
 
@@ -158,7 +158,7 @@ void reply_sends(struct smb_request *req)
 
        state = talloc(talloc_tos(), struct msg_state);
 
-       p = (const char *)req->buf + 1;
+       p = req->buf + 1;
        p += srvstr_pull_req_talloc(
                state, req, &state->from, p, STR_ASCII|STR_TERMINATE) + 1;
        p += srvstr_pull_req_talloc(
@@ -194,7 +194,7 @@ void reply_sends(struct smb_request *req)
 
 void reply_sendstrt(struct smb_request *req)
 {
-       const char *p;
+       const uint8_t *p;
 
        START_PROFILE(SMBsendstrt);
 
@@ -214,7 +214,7 @@ void reply_sendstrt(struct smb_request *req)
                return;
        }
 
-       p = (const char *)req->buf+1;
+       p = req->buf+1;
        p += srvstr_pull_req_talloc(
                req->sconn->conn->msg_state, req,
                &req->sconn->conn->msg_state->from, p,
index 36012e60d6aadfc50993222a866be1c2044a4f37..62c9728a4e8ef27e4c8f00c26abf9d40dde0b2d6 100644 (file)
@@ -836,7 +836,7 @@ size_t srvstr_get_path_req(TALLOC_CTX *mem_ctx, struct smb_request *req,
                           char **pp_dest, const char *src, int flags,
                           NTSTATUS *err);
 size_t srvstr_pull_req_talloc(TALLOC_CTX *ctx, struct smb_request *req,
-                             char **dest, const char *src, int flags);
+                             char **dest, const uint8_t *src, int flags);
 bool check_fsp_open(connection_struct *conn, struct smb_request *req,
                    files_struct *fsp);
 bool check_fsp(connection_struct *conn, struct smb_request *req,
index 9603975761eff9d08c0bf8582d9d63bf45d768fe..e58735ed93e474c4ffa7c7786276da849b5d1c3a 100644 (file)
@@ -345,7 +345,7 @@ size_t srvstr_get_path_req(TALLOC_CTX *mem_ctx, struct smb_request *req,
  * end of the smbbuf area
  */
 size_t srvstr_pull_req_talloc(TALLOC_CTX *ctx, struct smb_request *req,
-                             char **dest, const char *src, int flags)
+                             char **dest, const uint8_t *src, int flags)
 {
        ssize_t bufrem = smbreq_bufrem(req, src);
 
@@ -688,7 +688,8 @@ void reply_tcon(struct smb_request *req)
        char *dev = NULL;
        int pwlen=0;
        NTSTATUS nt_status;
-       const char *p;
+       const uint8_t *p;
+       const char *p2;
        TALLOC_CTX *ctx = talloc_tos();
        struct smbd_server_connection *sconn = req->sconn;
        NTTIME now = timeval_to_nttime(&req->request_time);
@@ -701,7 +702,7 @@ void reply_tcon(struct smb_request *req)
                return;
        }
 
-       p = (const char *)req->buf + 1;
+       p = req->buf + 1;
        p += srvstr_pull_req_talloc(ctx, req, &service_buf, p, STR_TERMINATE);
        p += 1;
        pwlen = srvstr_pull_req_talloc(ctx, req, &password, p, STR_TERMINATE);
@@ -714,9 +715,9 @@ void reply_tcon(struct smb_request *req)
                END_PROFILE(SMBtcon);
                return;
        }
-       p = strrchr_m(service_buf,'\\');
-       if (p) {
-               service = p+1;
+       p2 = strrchr_m(service_buf,'\\');
+       if (p2) {
+               service = p2+1;
        } else {
                service = service_buf;
        }
@@ -760,7 +761,8 @@ void reply_tcon_and_X(struct smb_request *req)
        NTSTATUS nt_status;
        int passlen;
        char *path = NULL;
-       const char *p, *q;
+       const uint8_t *p;
+       const char *q;
        uint16_t tcon_flags;
        struct smbXsrv_session *session = NULL;
        NTTIME now = timeval_to_nttime(&req->request_time);
@@ -815,9 +817,9 @@ void reply_tcon_and_X(struct smb_request *req)
        }
 
        if (sconn->smb1.negprot.encrypted_passwords) {
-               p = (const char *)req->buf + passlen;
+               p = req->buf + passlen;
        } else {
-               p = (const char *)req->buf + passlen + 1;
+               p = req->buf + passlen + 1;
        }
 
        p += srvstr_pull_req_talloc(ctx, req, &path, p, STR_TERMINATE);
index cf5c9f0d0e30b9c707f6a12a9fccdc92d1fcb40c..f719ec5233578d30d113df982f1873c3b6a59e21 100644 (file)
@@ -127,7 +127,6 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
        const char *native_os;
        const char *native_lanman;
        const char *primary_domain;
-       const char *p2;
        uint16 data_blob_len = SVAL(req->vwv+7, 0);
        enum remote_arch_types ra_type = get_remote_arch();
        uint64_t vuid = req->vuid;
@@ -165,17 +164,17 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
        file_save("negotiate.dat", in_blob.data, in_blob.length);
 #endif
 
-       p2 = (const char *)req->buf + in_blob.length;
+       p = req->buf + in_blob.length;
 
-       p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2,
+       p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p,
                                     STR_TERMINATE);
        native_os = tmp ? tmp : "";
 
-       p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2,
+       p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p,
                                     STR_TERMINATE);
        native_lanman = tmp ? tmp : "";
 
-       p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2,
+       p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p,
                                     STR_TERMINATE);
        primary_domain = tmp ? tmp : "";