summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/util/charset/util_str.c2
-rw-r--r--lib/util/charset/util_unistr_w.c6
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/include/smb.h2
-rw-r--r--source3/include/smb_macros.h1
-rw-r--r--source3/lib/tldap.c10
-rw-r--r--source3/lib/util.c4
-rw-r--r--source3/lib/winbind_util.c2
-rw-r--r--source3/librpc/crypto/gse.c44
-rw-r--r--source3/libsmb/libsmb_context.c6
-rw-r--r--source3/libsmb/libsmb_file.c2
-rw-r--r--source3/rpc_client/cli_pipe.c2
-rw-r--r--source3/smbd/aio.c4
-rw-r--r--source3/smbd/blocking.c4
-rw-r--r--source3/smbd/filename.c2
-rw-r--r--source3/smbd/ipc.c2
-rw-r--r--source3/smbd/nttrans.c4
-rw-r--r--source3/smbd/perfcount.c2
-rw-r--r--source3/smbd/pipes.c4
-rw-r--r--source3/smbd/process.c32
-rw-r--r--source3/smbd/proto.h2
-rw-r--r--source3/smbd/reply.c14
-rw-r--r--source3/smbd/seal.c2
-rw-r--r--source3/smbd/trans2.c6
-rw-r--r--source3/smbd/vfs.c2
-rw-r--r--source4/libcli/raw/smb.h2
26 files changed, 84 insertions, 81 deletions
diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c
index 4f4ca93cfdd..e76c1dbbf59 100644
--- a/lib/util/charset/util_str.c
+++ b/lib/util/charset/util_str.c
@@ -550,7 +550,7 @@ char *strstr_m(const char *src, const char *findstr)
DEBUG(0,("strstr_m: dest malloc fail\n"));
return NULL;
}
- retp = (char *)(s+strlen(s2));
+ retp = discard_const_p(char, (s+strlen(s2)));
TALLOC_FREE(src_w);
TALLOC_FREE(find_w);
TALLOC_FREE(s2);
diff --git a/lib/util/charset/util_unistr_w.c b/lib/util/charset/util_unistr_w.c
index 22f22ab754c..5b61d52e7f8 100644
--- a/lib/util/charset/util_unistr_w.c
+++ b/lib/util/charset/util_unistr_w.c
@@ -72,12 +72,12 @@ smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
smb_ucs2_t cp;
while (*(COPY_UCS2_CHAR(&cp,s))) {
if (c == cp) {
- return (smb_ucs2_t *)s;
+ return discard_const_p(smb_ucs2_t, s);
}
s++;
}
if (c == cp) {
- return (smb_ucs2_t *)s;
+ return discard_const_p(smb_ucs2_t, s);
}
return NULL;
@@ -104,7 +104,7 @@ smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c)
p += (len - 1);
do {
if (c == *(COPY_UCS2_CHAR(&cp,p))) {
- return (smb_ucs2_t *)p;
+ return discard_const_p(smb_ucs2_t, p);
}
} while (p-- != s);
return NULL;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2dd30d988b0..2305a7ac687 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -615,7 +615,7 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
bool socket_exist(const char *fname);
uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
SMB_OFF_T get_file_size(char *file_name);
-void show_msg(char *buf);
+void show_msg(const char *buf);
void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
void smb_setlen(char *buf,int len);
int set_message_bcc(char *buf,int num_bytes);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 57de387661a..28bc49f8584 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1205,7 +1205,7 @@ struct bitmap {
/* where to find the base of the SMB packet proper */
-#define smb_base(buf) (((char *)(buf))+4)
+#define smb_base(buf) (((const char *)(buf))+4)
/* we don't allow server strings to be longer than 48 characters as
otherwise NT will not honour the announce packets */
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 79aa4c54068..f7cfaaf325e 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -123,6 +123,7 @@
/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */
#define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2)
+#define smb_buf_const(buf) (((const char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2)
#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2))
/* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index ba27028649e..3afdaea4194 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -189,7 +189,7 @@ bool tldap_context_setattr(struct tldap_context *ld,
struct tldap_ctx_attribute *tmp, *attr;
char *tmpname;
int num_attrs;
- void **pptr = (void **)_pptr;
+ void **pptr = (void **)discard_const_p(void,_pptr);
attr = tldap_context_findattr(ld, name);
if (attr != NULL) {
@@ -935,10 +935,10 @@ struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx,
DATA_BLOB cred;
if (passwd != NULL) {
- cred.data = (uint8_t *)passwd;
+ cred.data = discard_const_p(uint8_t, passwd);
cred.length = strlen(passwd);
} else {
- cred.data = (uint8_t *)"";
+ cred.data = discard_const_p(uint8_t, "");
cred.length = 0;
}
return tldap_sasl_bind_send(mem_ctx, ev, ld, dn, NULL, &cred, NULL, 0,
@@ -956,10 +956,10 @@ int tldap_simple_bind(struct tldap_context *ld, const char *dn,
DATA_BLOB cred;
if (passwd != NULL) {
- cred.data = (uint8_t *)passwd;
+ cred.data = discard_const_p(uint8_t, passwd);
cred.length = strlen(passwd);
} else {
- cred.data = (uint8_t *)"";
+ cred.data = discard_const_p(uint8_t, "");
cred.length = 0;
}
return tldap_sasl_bind(ld, dn, NULL, &cred, NULL, 0, NULL, 0);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 718500a684f..cd856ee3556 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -298,7 +298,7 @@ SMB_OFF_T get_file_size(char *file_name)
Show a smb message structure.
********************************************************************/
-void show_msg(char *buf)
+void show_msg(const char *buf)
{
int i;
int bcc=0;
@@ -335,7 +335,7 @@ void show_msg(char *buf)
if (DEBUGLEVEL < 50)
bcc = MIN(bcc, 512);
- dump_data(10, (uint8 *)smb_buf(buf), bcc);
+ dump_data(10, (const uint8 *)smb_buf(buf), bcc);
}
/*******************************************************************
diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c
index f30bcfc6126..3fa1485d452 100644
--- a/source3/lib/winbind_util.c
+++ b/source3/lib/winbind_util.c
@@ -245,7 +245,7 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
(*types)[i] = (enum lsa_SidType)name_types[i];
}
- wbcFreeMemory(CONST_DISCARD(char*, dom_name));
+ wbcFreeMemory(discard_const_p(char, dom_name));
wbcFreeMemory(namelist);
wbcFreeMemory(name_types);
diff --git a/source3/librpc/crypto/gse.c b/source3/librpc/crypto/gse.c
index ca99f9b03ac..34742bc4aa1 100644
--- a/source3/librpc/crypto/gse.c
+++ b/source3/librpc/crypto/gse.c
@@ -365,8 +365,6 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx,
OM_uint32 gss_maj, gss_min;
krb5_error_code ret;
NTSTATUS status;
- const char *ktname;
- gss_OID_set_desc mech_set;
status = gse_context_init(mem_ctx, do_sign, do_seal,
NULL, add_gss_c_flags, &gse_ctx);
@@ -396,24 +394,27 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx,
* This call sets the default keytab for the whole server, not
* just for this context. Need to find a way that does not alter
* the state of the whole server ... */
+ {
+ const char *ktname;
+ gss_OID_set_desc mech_set;
- ret = smb_krb5_keytab_name(gse_ctx, gse_ctx->k5ctx,
+ ret = smb_krb5_keytab_name(gse_ctx, gse_ctx->k5ctx,
gse_ctx->keytab, &ktname);
- if (ret) {
- status = NT_STATUS_INTERNAL_ERROR;
- goto done;
- }
+ if (ret) {
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
+ }
- ret = gsskrb5_register_acceptor_identity(ktname);
- if (ret) {
- status = NT_STATUS_INTERNAL_ERROR;
- goto done;
- }
+ ret = gsskrb5_register_acceptor_identity(ktname);
+ if (ret) {
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
+ }
- mech_set.count = 1;
- mech_set.elements = &gse_ctx->gss_mech;
-
- gss_maj = gss_acquire_cred(&gss_min,
+ mech_set.count = 1;
+ mech_set.elements = &gse_ctx->gss_mech;
+
+ gss_maj = gss_acquire_cred(&gss_min,
GSS_C_NO_NAME,
GSS_C_INDEFINITE,
&mech_set,
@@ -421,11 +422,12 @@ NTSTATUS gse_init_server(TALLOC_CTX *mem_ctx,
&gse_ctx->creds,
NULL, NULL);
- if (gss_maj) {
- DEBUG(0, ("gss_acquire_creds failed with [%s]\n",
- gse_errstr(gse_ctx, gss_maj, gss_min)));
- status = NT_STATUS_INTERNAL_ERROR;
- goto done;
+ if (gss_maj) {
+ DEBUG(0, ("gss_acquire_creds failed with [%s]\n",
+ gse_errstr(gse_ctx, gss_maj, gss_min)));
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto done;
+ }
}
#endif
status = NT_STATUS_OK;
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index 9c8429aab47..f81631e5f61 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -456,11 +456,11 @@ smbc_option_get(SMBCCTX *context,
switch(smbc_getOptionSmbEncryptionLevel(context))
{
case 0:
- return (void *) "none";
+ return discard_const_p(void, "none");
case 1:
- return (void *) "request";
+ return discard_const_p(void, "request");
case 2:
- return (void *) "require";
+ return discard_const_p(void, "require");
}
} else if (strcmp(option_name, "smb_encrypt_on") == 0) {
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 4ab6cd22e53..e21eff30295 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -378,7 +378,7 @@ SMBC_write_ctx(SMBCCTX *context,
/*d_printf(">>>write: resolved path as %s\n", targetpath);*/
status = cli_writeall(targetcli, file->cli_fd,
- 0, (uint8_t *)buf, offset, count, NULL);
+ 0, (const uint8_t *)buf, offset, count, NULL);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
TALLOC_FREE(frame);
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index d5521da5097..24db5dcba6a 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -2581,7 +2581,7 @@ static NTSTATUS rpc_pipe_get_tcp_port(const char *host,
status = dcerpc_epm_Map(epm_handle,
tmp_ctx,
- CONST_DISCARD(struct GUID *,
+ discard_const_p(struct GUID,
&(abstract_syntax->uuid)),
map_tower,
entry_handle,
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 0cb94acece8..1923c945a80 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -251,7 +251,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
struct smb_request *smbreq,
- files_struct *fsp, char *data,
+ files_struct *fsp, const char *data,
SMB_OFF_T startpos,
size_t numtowrite)
{
@@ -329,7 +329,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
/* Now set up the aio record for the write call. */
a->aio_fildes = fsp->fh->fd;
- a->aio_buf = data;
+ a->aio_buf = discard_const_p(char, data);
a->aio_nbytes = numtowrite;
a->aio_offset = startpos;
a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index c208234bdcf..d125a744390 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -337,7 +337,7 @@ static void reply_lockingX_error(struct blocking_lock_record *blr, NTSTATUS stat
uint8_t *data;
int i;
- data = (uint8_t *)blr->req->buf
+ data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
/*
@@ -429,7 +429,7 @@ static bool process_lockingX(struct blocking_lock_record *blr)
uint8_t *data;
NTSTATUS status = NT_STATUS_OK;
- data = (uint8_t *)blr->req->buf
+ data = discard_const_p(uint8_t, blr->req->buf)
+ ((large_file_format ? 20 : 10)*num_ulocks);
/*
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 08bc79dfd22..f09dd12013b 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -167,7 +167,7 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx,
* here as last_component points
* into our smb_fname->base_name.
*/
- *pp_start = CONST_DISCARD(char *,last_component);
+ *pp_start = discard_const_p(char, last_component);
/* Update dirpath. */
TALLOC_FREE(*pp_dirpath);
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index f303e8f1713..7cc69045108 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -808,7 +808,7 @@ void reply_transs(struct smb_request *req)
START_PROFILE(SMBtranss);
- show_msg((char *)req->inbuf);
+ show_msg((const char *)req->inbuf);
if (req->wct < 8) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index f4bd969300e..33f05bd789e 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -2861,7 +2861,7 @@ static void handle_nttrans(connection_struct *conn,
{
if (get_Protocol() >= PROTOCOL_NT1) {
req->flags2 |= 0x40; /* IS_LONG_NAME */
- SSVAL(req->inbuf,smb_flg2,req->flags2);
+ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_flg2,req->flags2);
}
@@ -3203,7 +3203,7 @@ void reply_nttranss(struct smb_request *req)
START_PROFILE(SMBnttranss);
- show_msg((char *)req->inbuf);
+ show_msg((const char *)req->inbuf);
if (req->wct < 18) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
diff --git a/source3/smbd/perfcount.c b/source3/smbd/perfcount.c
index 3bc83b98d5f..15618937582 100644
--- a/source3/smbd/perfcount.c
+++ b/source3/smbd/perfcount.c
@@ -85,7 +85,7 @@ NTSTATUS smb_register_perfcounter(int interface_version, const char *name,
entry = SMB_XMALLOC_P(struct smb_perfcount_module);
entry->name = smb_xstrdup(name);
- entry->handlers = (struct smb_perfcount_handlers*) handlers;
+ entry->handlers = discard_const_p(struct smb_perfcount_handlers, handlers);
DLIST_ADD(modules, entry);
DEBUG(3, ("Successfully added perfcounter module '%s'\n", name));
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index 35dd9a74b90..c8829cd58a1 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -270,7 +270,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
{
files_struct *fsp = file_fsp(req, SVAL(req->vwv+2, 0));
int smb_doff = SVAL(req->vwv+11, 0);
- uint8_t *data;
+ const uint8_t *data;
struct pipe_write_andx_state *state;
struct tevent_req *subreq;
@@ -299,7 +299,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
DEBUG(6, ("reply_pipe_write_and_X: %x name: %s len: %d\n",
(int)fsp->fnum, fsp_str_dbg(fsp), (int)state->numtowrite));
- data = (uint8_t *)smb_base(req->inbuf) + smb_doff;
+ data = (const uint8_t *)smb_base(req->inbuf) + smb_doff;
if (state->pipe_start_message_raw) {
/*
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 169c4595346..9306aa3e93a 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -503,9 +503,9 @@ static bool init_smb_request(struct smb_request *req,
req->vuid = SVAL(inbuf, smb_uid);
req->tid = SVAL(inbuf, smb_tid);
req->wct = CVAL(inbuf, smb_wct);
- req->vwv = (uint16_t *)(inbuf+smb_vwv);
+ req->vwv = discard_const_p(uint16_t, (inbuf+smb_vwv));
req->buflen = smb_buflen(inbuf);
- req->buf = (const uint8_t *)smb_buf(inbuf);
+ req->buf = (const uint8_t *)smb_buf_const(inbuf);
req->unread_bytes = unread_bytes;
req->encrypted = encrypted;
req->sconn = sconn;
@@ -524,7 +524,7 @@ static bool init_smb_request(struct smb_request *req,
return false;
}
/* Ensure bcc is correct. */
- if (((uint8 *)smb_buf(inbuf)) + req->buflen > inbuf + req_size) {
+ if (((const uint8_t *)smb_buf_const(inbuf)) + req->buflen > inbuf + req_size) {
DEBUG(0,("init_smb_request: invalid bcc number %u "
"(wct = %u, size %u)\n",
(unsigned int)req->buflen,
@@ -1350,7 +1350,7 @@ static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
char *msg;
if (asprintf(&msg, "num_bytes too large: %u",
(unsigned)num_bytes) == -1) {
- msg = CONST_DISCARD(char *, "num_bytes too large");
+ msg = discard_const_p(char, "num_bytes too large");
}
smb_panic(msg);
}
@@ -1377,7 +1377,7 @@ static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
{
char *outbuf;
- if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words,
+ if (!create_outbuf(req, req, (const char *)req->inbuf, &outbuf, num_words,
num_bytes)) {
smb_panic("could not allocate output buffer\n");
}
@@ -1449,7 +1449,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
if (smb_messages[type].fn == NULL) {
DEBUG(0,("Unknown message type %d!\n",type));
- smb_dump("Unknown", 1, (char *)req->inbuf, size);
+ smb_dump("Unknown", 1, (const char *)req->inbuf, size);
reply_unknown_new(req, type);
return NULL;
}
@@ -1464,10 +1464,10 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type),
(int)sys_getpid(), (unsigned long)conn));
- smb_dump(smb_fn_name(type), 1, (char *)req->inbuf, size);
+ smb_dump(smb_fn_name(type), 1, (const char *)req->inbuf, size);
/* Ensure this value is replaced in the incoming packet. */
- SSVAL(req->inbuf,smb_uid,session_tag);
+ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_uid,session_tag);
/*
* Ensure the correct username is in current_user_info. This is a
@@ -1753,7 +1753,7 @@ static void construct_reply_common(struct smb_request *req, const char *inbuf,
void construct_reply_common_req(struct smb_request *req, char *outbuf)
{
- construct_reply_common(req, (char *)req->inbuf, outbuf);
+ construct_reply_common(req, (const char *)req->inbuf, outbuf);
}
/*
@@ -1976,9 +1976,9 @@ void chain_reply(struct smb_request *req)
uint32_t chain_offset; /* uint32_t to avoid overflow */
uint8_t wct;
- uint16_t *vwv;
+ const uint16_t *vwv;
uint16_t buflen;
- uint8_t *buf;
+ const uint8_t *buf;
if (IVAL(req->outbuf, smb_rcls) != 0) {
fixup_chain_error_packet(req);
@@ -2127,7 +2127,7 @@ void chain_reply(struct smb_request *req)
if (length_needed > smblen) {
goto error;
}
- vwv = (uint16_t *)(smb_base(req->inbuf) + chain_offset + 1);
+ vwv = (const uint16_t *)(smb_base(req->inbuf) + chain_offset + 1);
/*
* Now grab the new byte buffer....
@@ -2143,11 +2143,11 @@ void chain_reply(struct smb_request *req)
if (length_needed > smblen) {
goto error;
}
- buf = (uint8_t *)(vwv+wct+1);
+ buf = (const uint8_t *)(vwv+wct+1);
req->cmd = chain_cmd;
req->wct = wct;
- req->vwv = vwv;
+ req->vwv = discard_const_p(uint16_t, vwv);
req->buflen = buflen;
req->buf = buf;
@@ -2613,7 +2613,7 @@ static bool smbd_echo_reply(uint8_t *inbuf, size_t inbuf_len,
return false;
}
- if (!create_outbuf(talloc_tos(), &req, (char *)req.inbuf, &outbuf,
+ if (!create_outbuf(talloc_tos(), &req, (const char *)req.inbuf, &outbuf,
1, req.buflen)) {
DEBUG(10, ("create_outbuf failed\n"));
return false;
@@ -3162,7 +3162,7 @@ void smbd_process(struct smbd_server_connection *sconn)
bool req_is_in_chain(struct smb_request *req)
{
- if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+ if (req->vwv != (const uint16_t *)(req->inbuf+smb_vwv)) {
/*
* We're right now handling a subsequent request, so we must
* be in a chain
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 86745f122dd..2ea01c2a5ea 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -23,7 +23,7 @@ NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
size_t smb_maxcnt);
NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
struct smb_request *req,
- files_struct *fsp, char *data,
+ files_struct *fsp, const char *data,
SMB_OFF_T startpos,
size_t numtowrite);
NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9c66ddee029..fc381d89e7f 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -314,7 +314,7 @@ size_t srvstr_get_path_req_wcard(TALLOC_CTX *mem_ctx, struct smb_request *req,
char **pp_dest, const char *src, int flags,
NTSTATUS *err, bool *contains_wcard)
{
- return srvstr_get_path_wcard(mem_ctx, (char *)req->inbuf, req->flags2,
+ return srvstr_get_path_wcard(mem_ctx, (const char *)req->inbuf, req->flags2,
pp_dest, src, smbreq_bufrem(req, src),
flags, err, contains_wcard);
}
@@ -873,7 +873,7 @@ void reply_tcon_and_X(struct smb_request *req)
service));
/* set the incoming and outgoing tid to the just created one */
- SSVAL(req->inbuf,smb_tid,conn->cnum);
+ SSVAL(discard_const_p(uint8_t, req->inbuf),smb_tid,conn->cnum);
SSVAL(req->outbuf,smb_tid,conn->cnum);
END_PROFILE(SMBtconX);
@@ -3896,7 +3896,7 @@ void reply_writebraw(struct smb_request *req)
size_t numtowrite=0;
size_t tcount;
SMB_OFF_T startpos;
- char *data=NULL;
+ const char *data=NULL;
bool write_through;
files_struct *fsp;
struct lock_struct lock;
@@ -3909,7 +3909,7 @@ void reply_writebraw(struct smb_request *req)
* type of SMBwritec, not SMBwriteBraw, as this tells the client
* we're finished.
*/
- SCVAL(req->inbuf,smb_com,SMBwritec);
+ SCVAL(discard_const_p(uint8_t, req->inbuf),smb_com,SMBwritec);
if (srv_is_signing_active(req->sconn)) {
END_PROFILE(SMBwritebraw);
@@ -3955,8 +3955,8 @@ void reply_writebraw(struct smb_request *req)
on whether we are using the core+ or lanman1.0 protocol */
if(get_Protocol() <= PROTOCOL_COREPLUS) {
- numtowrite = SVAL(smb_buf(req->inbuf),-2);
- data = smb_buf(req->inbuf);
+ numtowrite = SVAL(smb_buf_const(req->inbuf),-2);
+ data = smb_buf_const(req->inbuf);
} else {
numtowrite = SVAL(req->vwv+10, 0);
data = smb_base(req->inbuf) + SVAL(req->vwv+11, 0);
@@ -4474,7 +4474,7 @@ void reply_write_and_X(struct smb_request *req)
ssize_t nwritten;
unsigned int smb_doff;
unsigned int smblen;
- char *data;
+ const char *data;
NTSTATUS status;
int saved_errno = 0;
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
index b3dd84264a8..a34a19a684d 100644
--- a/source3/smbd/seal.c
+++ b/source3/smbd/seal.c
@@ -133,7 +133,7 @@ static NTSTATUS get_srv_gss_creds(const char *service,
NTSTATUS status = NT_STATUS_OK;
gss_OID_desc nt_hostbased_service =
- {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
+ {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
if (asprintf(&host_princ_s, "%s@%s", service, name) == -1) {
return NT_STATUS_NO_MEMORY;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 7c8b43c10c0..733f1bc2a81 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -8322,7 +8322,7 @@ static void call_trans2getdfsreferral(connection_struct *conn,
return;
}
- SSVAL(req->inbuf, smb_flg2,
+ SSVAL((discard_const_p(uint8_t, req->inbuf)), smb_flg2,
SVAL(req->inbuf,smb_flg2) | FLAGS2_DFS_PATHNAMES);
send_trans2_replies(conn, req,0,0,*ppdata,reply_size, max_data_bytes);
@@ -8453,7 +8453,7 @@ static void handle_trans2(connection_struct *conn, struct smb_request *req,
{
if (get_Protocol() >= PROTOCOL_NT1) {
req->flags2 |= 0x40; /* IS_LONG_NAME */
- SSVAL(req->inbuf,smb_flg2,req->flags2);
+ SSVAL((discard_const_p(uint8_t, req->inbuf)),smb_flg2,req->flags2);
}
if (conn->encrypt_level == Required && !req->encrypted) {
@@ -8812,7 +8812,7 @@ void reply_transs2(struct smb_request *req)
START_PROFILE(SMBtranss2);
- show_msg((char *)req->inbuf);
+ show_msg((const char *)req->inbuf);
if (req->wct < 8) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 3bde0a388e5..e6ea34bd184 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1506,7 +1506,7 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
}
ZERO_STRUCT(local_fname);
- local_fname.base_name = CONST_DISCARD(char *,final_component);
+ local_fname.base_name = discard_const_p(char, final_component);
/* Must use lstat here. */
ret = SMB_VFS_LSTAT(fsp->conn, &local_fname);
diff --git a/source4/libcli/raw/smb.h b/source4/libcli/raw/smb.h
index f1d0bfd294f..008ab57c0de 100644
--- a/source4/libcli/raw/smb.h
+++ b/source4/libcli/raw/smb.h
@@ -454,7 +454,7 @@
/* where to find the base of the SMB packet proper */
/* REWRITE TODO: smb_base needs to be removed */
-#define smb_base(buf) (((char *)(buf))+4)
+#define smb_base(buf) (((const char *)(buf))+4)
/* we don't allow server strings to be longer than 48 characters as
otherwise NT will not honour the announce packets */