From: Stefan Metzmacher Date: Mon, 30 Mar 2026 15:17:47 +0000 (+0200) Subject: C26: const-qualify variables for read-only strchr/strrchr/strstr results X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=cb690b465adef7dc8cfccd4c1b0c1ea826c0a2ff;p=thirdparty%2Fsamba.git C26: const-qualify variables for read-only strchr/strrchr/strstr results In C26, strchr/strrchr/strstr return const char * when given const char * input. Add const to local variables that only read through the pointer. Pair-Programmed-With: Andreas Schneider BUG: https://bugzilla.samba.org/show_bug.cgi?id=16006 Signed-off-by: Andreas Schneider Signed-off-by: Stefan Metzmacher --- diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index d8f12fa87ba..8365fc2e1fd 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -240,7 +240,7 @@ static int ipv6_from_string(const char *str, struct sockaddr_in6 *ip6) static int ip_from_string(const char *str, ctdb_sock_addr *addr) { - char *p; + const char *p; int ret; if (addr == NULL) { diff --git a/lib/addns/dnsquery_srv.c b/lib/addns/dnsquery_srv.c index ac9e612b8f9..6c4f06dd898 100644 --- a/lib/addns/dnsquery_srv.c +++ b/lib/addns/dnsquery_srv.c @@ -339,7 +339,7 @@ struct tevent_req *ads_dns_query_srv_send( state->query = query; if ((sitename != NULL) && (sitename[0] != '\0')) { - char *after_tcp = NULL; + const char *after_tcp = NULL; char *site_aware = NULL; /* diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c index f96ca88f95b..caedbd45bbd 100644 --- a/lib/cmdline/cmdline.c +++ b/lib/cmdline/cmdline.c @@ -203,7 +203,7 @@ static bool is_password_option(const char *p, size_t *ulen) "--with-smbpasswd-file", }; - char *equals = NULL; + const char *equals = NULL; *ulen = 0; for (i = 0; i < ARRAY_SIZE(must_burn); i++) { @@ -242,7 +242,7 @@ static bool is_password_option(const char *p, size_t *ulen) if (equals == NULL) { *ulen = strlen(p); } else { - char *pass = (strstr(p, "pass")); + const char *pass = (strstr(p, "pass")); if (pass > equals) { /* this is --foo=pass, not --pass=foo */ return false; diff --git a/lib/ldb/common/ldb_ldif.c b/lib/ldb/common/ldb_ldif.c index 24a0bcdefa5..b60ffe312a8 100644 --- a/lib/ldb/common/ldb_ldif.c +++ b/lib/ldb/common/ldb_ldif.c @@ -110,7 +110,7 @@ int ldb_base64_decode(char *s) const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int bit_offset=0, byte_offset, idx, i, n; uint8_t *d = (uint8_t *)s; - char *p=NULL; + const char *p=NULL; n=i=0; diff --git a/lib/ldb/common/ldb_modules.c b/lib/ldb/common/ldb_modules.c index 04f27e6918f..0d11e0c4e9e 100644 --- a/lib/ldb/common/ldb_modules.c +++ b/lib/ldb/common/ldb_modules.c @@ -197,7 +197,7 @@ int ldb_module_connect_backend(struct ldb_context *ldb, int ret; char *backend; struct backends_list_entry *be; - char *colon = NULL; + const char *colon = NULL; colon = strchr(url, ':'); if (colon != NULL) { diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c index 1f4c99a00ff..6f2dcd19a0b 100644 --- a/lib/tdb/tools/tdbtool.c +++ b/lib/tdb/tools/tdbtool.c @@ -131,7 +131,7 @@ static void tdb_log_open(struct tdb_context *tdb, enum tdb_debug_level level, { const char *mutex_msg = "Can use mutexes only with MUTEX_LOCKING or NOLOCK\n"; - char *p; + const char *p; va_list ap; p = strstr(format, mutex_msg); diff --git a/lib/util/base64.c b/lib/util/base64.c index 7acc83d0eaf..99fda0bfa3b 100644 --- a/lib/util/base64.c +++ b/lib/util/base64.c @@ -39,7 +39,7 @@ _PUBLIC_ DATA_BLOB base64_decode_data_blob_talloc(TALLOC_CTX *mem_ctx, const cha int bit_offset, byte_offset, idx, i, n; DATA_BLOB decoded = data_blob_talloc(mem_ctx, s, strlen(s)+1); unsigned char *d = decoded.data; - char *p; + const char *p; if (decoded.data == NULL) { decoded.length = 0; diff --git a/lib/util/dns_cmp.c b/lib/util/dns_cmp.c index e20c4297963..c9b8a7d64f8 100644 --- a/lib/util/dns_cmp.c +++ b/lib/util/dns_cmp.c @@ -88,7 +88,7 @@ int dns_cmp(const char *s1, const char *s2) } for (i = 0; i < ARRAY_SIZE(comp1); i++) { - char *p; + const char *p; if (i == 0) { p1 = s1; @@ -118,7 +118,7 @@ int dns_cmp(const char *s1, const char *s2) } for (i = 0; i < ARRAY_SIZE(comp2); i++) { - char *p; + const char *p; if (i == 0) { p2 = s2; diff --git a/lib/util/smb_strtox.c b/lib/util/smb_strtox.c index 7a477dc8aaa..417140b5122 100644 --- a/lib/util/smb_strtox.c +++ b/lib/util/smb_strtox.c @@ -52,7 +52,7 @@ smb_strtoul(const char *nptr, char **endptr, int base, int *err, int flags) { unsigned long int val; int saved_errno = errno; - char *needle = NULL; + const char *needle = NULL; char *tmp_endptr = NULL; errno = 0; @@ -128,7 +128,7 @@ smb_strtoull(const char *nptr, char **endptr, int base, int *err, int flags) { unsigned long long int val; int saved_errno = errno; - char *needle = NULL; + const char *needle = NULL; char *tmp_endptr = NULL; errno = 0; diff --git a/lib/util/util_net.c b/lib/util/util_net.c index e410cdf915a..9ac91807b18 100644 --- a/lib/util/util_net.c +++ b/lib/util/util_net.c @@ -186,7 +186,7 @@ bool interpret_string_addr_internal(struct addrinfo **ppres, } if (strchr_m(str, ':')) { - char *p = strchr_m(str, SCOPE_DELIMITER); + const char *p = strchr_m(str, SCOPE_DELIMITER); /* * Cope with link-local. @@ -475,7 +475,7 @@ bool is_ipaddress_v6(const char *str) { #if defined(HAVE_IPV6) int ret = -1; - char *p = NULL; + const char *p = NULL; char buf[INET6_ADDRSTRLEN] = { 0, }; size_t len; const char *addr = str; diff --git a/libcli/auth/netlogon_creds_cli.c b/libcli/auth/netlogon_creds_cli.c index 879f79c5400..736c2f114ca 100644 --- a/libcli/auth/netlogon_creds_cli.c +++ b/libcli/auth/netlogon_creds_cli.c @@ -116,7 +116,7 @@ static NTSTATUS netlogon_creds_cli_context_common( struct netlogon_creds_cli_context *context = NULL; char *_key_name = NULL; size_t server_netbios_name_len; - char *p = NULL; + const char *p = NULL; *_context = NULL; diff --git a/libcli/nbt/tools/nmblookup.c b/libcli/nbt/tools/nmblookup.c index 6ca38faa863..75c6bed0b7a 100644 --- a/libcli/nbt/tools/nmblookup.c +++ b/libcli/nbt/tools/nmblookup.c @@ -190,7 +190,7 @@ static bool process_one(struct loadparm_context *lp_ctx, struct tevent_context * { TALLOC_CTX *tmp_ctx = talloc_new(NULL); enum nbt_name_type node_type = NBT_NAME_CLIENT; - char *node_name, *p; + const char *node_name, *p; struct socket_address *all_zero_addr; struct nbt_name_socket *nbtsock; NTSTATUS status = NT_STATUS_OK; diff --git a/libcli/security/tests/test_sddl_conditional_ace.c b/libcli/security/tests/test_sddl_conditional_ace.c index fd2473a8fff..77538c90bf7 100644 --- a/libcli/security/tests/test_sddl_conditional_ace.c +++ b/libcli/security/tests/test_sddl_conditional_ace.c @@ -902,7 +902,7 @@ static void test_a_number_of_invalid_full_sddl_strings(void **state) } if (cases[i].snippet != NULL) { if (message != NULL) { - char *c = strstr(message, cases[i].snippet); + const char *c = strstr(message, cases[i].snippet); print_error_message(cases[i].sddl, message, message_offset); diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c index 1c2634bc80d..cb9edb4bc7b 100644 --- a/nsswitch/pam_winbind.c +++ b/nsswitch/pam_winbind.c @@ -2328,7 +2328,7 @@ static const char *get_conf_item_string(struct pwb_context *ctx, for (i=0; iargc; i++) { if ((strncmp(ctx->argv[i], item, strlen(item)) == 0)) { - char *p; + const char *p; if ((p = strchr(ctx->argv[i], '=')) == NULL) { _pam_log(ctx, LOG_INFO, @@ -2374,7 +2374,7 @@ static int get_config_item_int(struct pwb_context *ctx, for (i = 0; i < ctx->argc; i++) { if ((strncmp(ctx->argv[i], item, strlen(item)) == 0)) { - char *p; + const char *p; if ((p = strchr(ctx->argv[i], '=')) == NULL) { _pam_log(ctx, LOG_INFO, diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c index 2f040728723..9515749aa7b 100644 --- a/nsswitch/wbinfo.c +++ b/nsswitch/wbinfo.c @@ -116,7 +116,7 @@ static bool parse_wbinfo_domain_user(const char *domuser, fstring domain, fstring user) { - char *p = strchr(domuser,winbind_separator()); + const char *p = strchr(domuser,winbind_separator()); if (!p) { /* Maybe it was a UPN? */ diff --git a/source3/auth/auth_generic.c b/source3/auth/auth_generic.c index a5cfd69c506..e94ecef467d 100644 --- a/source3/auth/auth_generic.c +++ b/source3/auth/auth_generic.c @@ -52,7 +52,7 @@ static NTSTATUS generate_pac_session_info( struct wbcAuthErrorInfo *err = NULL; struct auth_serversupplied_info *server_info = NULL; char *original_user_name = NULL; - char *p = NULL; + const char *p = NULL; wbcErr wbc_err; /* diff --git a/source3/auth/user_krb5.c b/source3/auth/user_krb5.c index 169bf563368..10c98fcc161 100644 --- a/source3/auth/user_krb5.c +++ b/source3/auth/user_krb5.c @@ -42,7 +42,7 @@ NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx, const char *domain = NULL; const char *realm = NULL; char *user = NULL; - char *p; + const char *p = NULL; char *fuser = NULL; char *unixuser = NULL; struct passwd *pw = NULL; diff --git a/source3/lib/util.c b/source3/lib/util.c index 3308654d236..531af25dc27 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -576,7 +576,7 @@ void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size, char *get_mydnsdomname(TALLOC_CTX *ctx) { const char *domname; - char *p; + const char *p; domname = get_mydnsfullname(); if (!domname) { @@ -1331,7 +1331,7 @@ char *myhostname_upper(void) bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent, const char **name) { - char *p; + const char *p; ptrdiff_t len; p = strrchr_m(dir, '/'); /* Find final '/', if any */ diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 6ab5d46f158..d8eaa10a8db 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -1461,7 +1461,7 @@ static bool windows_parent_dirname(TALLOC_CTX *mem_ctx, char **parent, const char **name) { - char *p; + const char *p; ptrdiff_t len; p = strrchr_m(dir, '\\'); /* Find final '\\', if any */ diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 0bcbf532873..78d14730154 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -2532,7 +2532,7 @@ static struct tevent_req *cli_connect_nb_send( state->transports = *transports; if (host != NULL) { - char *p = strchr(host, '#'); + const char *p = strchr(host, '#'); if (p != NULL) { name_type = strtol(p+1, NULL, 16); diff --git a/source3/modules/nfs4acl_xattr_nfs.c b/source3/modules/nfs4acl_xattr_nfs.c index bb2ceeee864..6c35ac32827 100644 --- a/source3/modules/nfs4acl_xattr_nfs.c +++ b/source3/modules/nfs4acl_xattr_nfs.c @@ -69,7 +69,7 @@ static struct nfs4_to_smb4_id_map { static bool is_special_nfs4_id(const char *nfs4_id) { - char *at = NULL; + const char *at = NULL; at = strchr(nfs4_id, '@'); if (at == NULL) { diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 8ac0ff346ae..f41b355a0de 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -5333,7 +5333,7 @@ static bool fruit_tmsize_do_dirent(vfs_handle_struct *handle, const char *name) { bool ok; - char *p = NULL; + const char *p = NULL; size_t sparsebundle_strlen = strlen("sparsebundle"); size_t bandsize = 0; size_t nbands; diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 0fe872ea69b..7e22ff8b2d5 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -392,7 +392,7 @@ static int alloc_get_client_path(vfs_handle_struct *handle, * - with suffixed name. */ int status = 0; - char* pathPtr; + const char *pathPtr = NULL; size_t intermPathLen; DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", path)); @@ -406,8 +406,9 @@ static int alloc_get_client_path(vfs_handle_struct *handle, goto out; } DEBUG(MH_INFO_DEBUG, ("newPath #1 %s\n", *newPath)); + pathPtr = strstr_m(path, CREATING_DIRNAME); if ( - (pathPtr = strstr(path, CREATING_DIRNAME)) != NULL + pathPtr != NULL && ( *(pathPtr + CREATING_DIRNAME_LEN) == '\0' diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 0c47f09268b..62ceddcd190 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -2951,7 +2951,7 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle, basedir); basedir = NULL; } else { - char *p; + const char *p; p = strstr(basedir, config->mount_point); if (p != basedir) { DEBUG(1, ("Warning: basedir (%s) is not a " diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 4d8b81bdc9d..a8cc9cd10bd 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -497,7 +497,7 @@ static int streams_xattr_get_name(vfs_handle_struct *handle, char **xattr_name) { size_t stream_name_len = strlen(stream_name); - char *stype; + const char *stype; struct streams_xattr_config *config; char *raw_stream_name = NULL; diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c index 84970998ff6..63afbe4d928 100644 --- a/source3/modules/vfs_unityed_media.c +++ b/source3/modules/vfs_unityed_media.c @@ -343,7 +343,7 @@ static int alloc_get_client_path(vfs_handle_struct *handle, char **path_out) { int status = 0; - char *p; + const char *p = NULL; char *digits; size_t digits_len; uintmax_t number; diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c index a6e167df126..9f177b56129 100644 --- a/source3/modules/vfs_virusfilter.c +++ b/source3/modules/vfs_virusfilter.c @@ -206,7 +206,7 @@ static int virusfilter_vfs_connect( const char *rename_prefix = NULL; const char *rename_suffix = NULL; const char *socket_path = NULL; - char *sret = NULL; + const char *sret = NULL; char *tmp = NULL; enum virusfilter_scanner_enum backend; int connect_timeout = 0; @@ -1264,7 +1264,7 @@ static int virusfilter_vfs_openat(struct vfs_handle_struct *handle, int rename_trap_count = 0; int ret; bool ok1; - char *sret = NULL; + const char *sret = NULL; struct smb_filename *smb_fname = NULL; SMB_STRUCT_STAT sbuf = smb_fname_in->st; diff --git a/source3/param/util.c b/source3/param/util.c index 94036f0df29..d4aaee19786 100644 --- a/source3/param/util.c +++ b/source3/param/util.c @@ -25,7 +25,7 @@ **********************************************************/ uint32_t get_int_param( const char* param ) { - char *p; + const char *p = NULL; p = strchr( param, '=' ); if ( !p ) diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c index 61c67b7a809..ba254f7ee09 100644 --- a/source3/passdb/lookup_sid.c +++ b/source3/passdb/lookup_sid.c @@ -82,7 +82,7 @@ static NTSTATUS lookup_name_internal(TALLOC_CTX *mem_ctx, struct dom_sid *ret_sid, enum lsa_SidType *ret_type) { - char *p; + const char *p; const char *tmp; const char *domain = NULL; const char *name = NULL; @@ -104,7 +104,7 @@ static NTSTATUS lookup_name_internal(TALLOC_CTX *mem_ctx, PTR_DIFF(p, full_name)); name = talloc_strdup(tmp_ctx, p+1); } else { - char *q = strchr_m(full_name, '@'); + const char *q = strchr_m(full_name, '@'); /* Set the domain for UPNs */ if (q != NULL) { diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c index 2b2215eb8c3..52649d94e4b 100644 --- a/source3/printing/print_iprint.c +++ b/source3/printing/print_iprint.c @@ -121,10 +121,10 @@ static int iprint_get_server_version(http_t *http, char* serviceUri) *response = NULL; /* IPP Response */ ipp_attribute_t *attr; /* Current attribute */ cups_lang_t *language = NULL; /* Default language */ - char *ver; /* server version pointer */ + const char *ver; /* server version pointer */ char *vertmp; /* server version tmp pointer */ int serverVersion = 0; /* server version */ - char *os; /* server os */ + const char *os; /* server os */ int osFlag = 0; /* 0 for NetWare, 1 for anything else */ char *temp; /* pointer for string manipulation */ diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index cb3b7da45a1..1d3c4484479 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -416,7 +416,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx, const char *filename_in, uint32_t ucf_flags) { - char *last_slash = NULL; + const char *last_slash = NULL; char *orig_lcomp; NTSTATUS status; diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c index 6a3cb33a5de..f3c87df97f7 100644 --- a/source3/smbd/mangle_hash.c +++ b/source3/smbd/mangle_hash.c @@ -750,7 +750,7 @@ static void init_chartest( void ) static bool is_mangled(const char *s, const struct share_params *p) { - char *magic; + const char *magic = NULL; char magic_char; magic_char = lp_mangling_char(p); diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c index 0075d3bfcba..fdedb7571da 100644 --- a/source3/smbd/mangle_hash2.c +++ b/source3/smbd/mangle_hash2.c @@ -440,7 +440,7 @@ static const char force_shortname_chars[] = " +,[];="; static bool is_8_3(const char *name, bool check_case, bool allow_wildcards, const struct share_params *p) { int len, i; - char *dot_p; + const char *dot_p = NULL; /* as a special case, the names '.' and '..' are allowable 8.3 names */ if (ISDOT(name) || (ISDOTDOT(name))) { @@ -684,7 +684,7 @@ static bool hash2_name_to_8_3(const char *name, int default_case, const struct share_params *p) { - char *dot_p; + const char *dot_p = NULL; char lead_chars[7]; char extension[4]; unsigned int extension_length, i; diff --git a/source3/smbd/smb1_lanman.c b/source3/smbd/smb1_lanman.c index 8bcddcbb8c2..6e518d6cc30 100644 --- a/source3/smbd/smb1_lanman.c +++ b/source3/smbd/smb1_lanman.c @@ -724,7 +724,7 @@ static void fill_printq_info_52(struct spoolss_DriverInfo3 *driver, static const char *strip_unc(const char *unc) { - char *p; + const char *p = NULL; if (unc == NULL) { return NULL; diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index 5aee828b496..cd12dbc143b 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -1083,14 +1083,15 @@ static void make_dir_struct(char *buf, time_t date, bool uc) { - char *p; + const char *p = NULL; if ((mode & FILE_ATTRIBUTE_DIRECTORY) != 0) { size = 0; } memset(buf+1,' ',11); - if ((p = strchr_m(mask, '.')) != NULL) { + p = strchr_m(mask, '.'); + if (p != NULL) { char name[p - mask + 1]; strlcpy(name, mask, sizeof(name)); push_ascii(buf + 1, name, 8, 0); diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 3048d95b5f2..91090d8857e 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -2540,7 +2540,7 @@ static int net_ads_password(struct net_context *c, int argc, const char **argv) const char *auth_password = cli_credentials_get_password(c->creds); const char *realm = NULL; char *new_password = NULL; - char *chr = NULL; + const char *chr = NULL; char *prompt = NULL; const char *user = NULL; char pwd[256] = {0}; @@ -3139,7 +3139,7 @@ static int net_ads_kerberos_pac_dump(struct net_context *c, int argc, const char static int net_ads_kerberos_pac_save(struct net_context *c, int argc, const char **argv) { struct PAC_DATA_CTR *pac_data_ctr = NULL; - char *filename = NULL; + const char *filename = NULL; int ret = -1; int i; diff --git a/source3/utils/net_vfs.c b/source3/utils/net_vfs.c index f38650ae1c3..6547ba1c897 100644 --- a/source3/utils/net_vfs.c +++ b/source3/utils/net_vfs.c @@ -320,7 +320,7 @@ done: static bool do_unfruit(const char *path) { struct smb_filename *smb_fname = NULL; - char *p = NULL; + const char *p = NULL; bool converted; NTSTATUS status; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index d32a9850980..83756f6271b 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -386,7 +386,7 @@ static bool parse_ntlm_auth_domain_user(const char *domuser, fstring domain, fstring user) { - char *p = strchr(domuser,winbind_separator()); + const char *p = strchr(domuser,winbind_separator()); if (!p) { return False; diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index ea7c56e6566..02f88684877 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -68,7 +68,7 @@ static struct security_descriptor* parse_acl_string(TALLOC_CTX *mem_ctx, const c return NULL; for ( i=0; istring, ".."); - if (p != NULL) { - TALLOC_FREE(frame); - return NT_STATUS_INVALID_PARAMETER; + { + const char *dots = NULL; + + dots = strstr_m(ntln->string, ".."); + if (dots != NULL) { + TALLOC_FREE(frame); + return NT_STATUS_INVALID_PARAMETER; + } } if (nnb != NULL && diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c index 0c218e7f335..01fb1756112 100644 --- a/source4/dsdb/samdb/ldb_modules/partition_init.c +++ b/source4/dsdb/samdb/ldb_modules/partition_init.c @@ -94,7 +94,7 @@ static int partition_load_modules(struct ldb_context *ldb, } for (i=0; i < modules_attributes->num_values; i++) { - char *p; + const char *p; DATA_BLOB dn_blob; data->modules[i] = talloc(data->modules, struct partition_module); if (!data->modules[i]) { @@ -111,7 +111,7 @@ static int partition_load_modules(struct ldb_context *ldb, return LDB_ERR_CONSTRAINT_VIOLATION; } /* Now trim off the filename */ - dn_blob.length = ((uint8_t *)p - dn_blob.data); + dn_blob.length = ((const uint8_t *)p - dn_blob.data); p++; data->modules[i]->modules = ldb_modules_list_from_string(ldb, data->modules[i], @@ -457,7 +457,7 @@ int partition_reload_if_required(struct ldb_module *module, (strncmp((const char *)&dn_blob.data[dn_blob.length-4], ".ldb", 4) == 0)) { /* Look for DN:filename.ldb */ - char *p = strrchr((const char *)dn_blob.data, ':'); + const char *p = strrchr((const char *)dn_blob.data, ':'); if (!p) { ldb_asprintf_errstring(ldb, "partition_init: invalid DN in attempting to parse partition record: %s", (const char *)dn_blob.data); @@ -467,7 +467,7 @@ int partition_reload_if_required(struct ldb_module *module, filename = p+1; /* Now trim off the filename */ - dn_blob.length = ((uint8_t *)p - dn_blob.data); + dn_blob.length = ((const uint8_t *)p - dn_blob.data); } dn = ldb_dn_from_ldb_val(mem_ctx, ldb, &dn_blob); diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c index b010abb8ab4..6cb313773d6 100644 --- a/source4/dsdb/samdb/ldb_modules/ranged_results.c +++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c @@ -114,7 +114,8 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) /* Find those that are range requests from the attribute list */ for (i = 0; ac->req->op.search.attrs[i]; i++) { - char *p, *new_attr; + const char *p; + char *new_attr; const char *end_str; unsigned int start, end; struct ldb_message_element *el; @@ -221,7 +222,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) /* Strip the range request from the attribute */ for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { - char *p; + const char *p; size_t range_len = strlen(";range="); new_attrs = talloc_realloc(req, new_attrs, const char *, i+2); diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 7541a2cf376..364c118c70d 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -1145,7 +1145,8 @@ static int get_optional_feature_dn_guid(struct ldb_request *req, struct ldb_cont { const struct ldb_message *msg = req->op.mod.message; const char *ldb_val_str; - char *dn, *guid; + char *dn; + const char *guid; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); NTSTATUS status; diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 99d183e14e5..d5c0efd8710 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -362,7 +362,8 @@ static int samaccountname_bad_chars_check(struct samldb_ctx *ac, for (i = 0; name[i] != '\0'; i++) { uint8_t c = name[i]; - char *p = NULL; + const char *p = NULL; + if (c < 32 || c == 127) { ldb_asprintf_errstring( ldb, @@ -3821,8 +3822,8 @@ static int check_spn_alias_collision(struct ldb_context *ldb, { int ret; char *service_class = NULL; - char *spn_tail = NULL; - char *p = NULL; + const char *spn_tail = NULL; + const char *p = NULL; char **aliases = NULL; size_t n_aliases = 0; size_t i, len; diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index 1197adba7f1..014da161f85 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -90,7 +90,7 @@ static DATA_BLOB reg_strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *str) DATA_BLOB ret; const char *HEXCHARS = "0123456789ABCDEF"; size_t i, j; - char *hi, *lo; + const char *hi, *lo; ret = data_blob_talloc_zero(mem_ctx, (strlen(str)+(strlen(str) % 3))/3); j = 0; diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c index 62dbf1d2213..4c33fc4af0a 100644 --- a/source4/lib/socket/socket_ip.c +++ b/source4/lib/socket/socket_ip.c @@ -561,7 +561,7 @@ static struct in6_addr interpret_addr6(const char *name) char addr[INET6_ADDRSTRLEN]; struct in6_addr dest6; const char *sp = name; - char *p; + const char *p = NULL; int ret; if (sp == NULL) return in6addr_any; diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index a43f91070bd..7fa9c948e1c 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -178,7 +178,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, } if (strncmp(sharename, "\\\\", 2) == 0) { - char *str = strchr(sharename+2, '\\'); + const char *str = strchr(sharename+2, '\\'); if (str) { sharename = str + 1; } diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 01e2a5deef4..452f13ee594 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -123,7 +123,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, } if (strncmp(sharename, "\\\\", 2) == 0) { - char *p = strchr(sharename+2, '\\'); + const char *p = strchr(sharename+2, '\\'); if (p) { sharename = p + 1; } diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index de0ae2ce828..be05b11e978 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -122,7 +122,7 @@ static NTSTATUS ntvfs_map_async_finish(struct ntvfs_request *req, NTSTATUS statu */ bool is_exe_filename(const char *fname) { - char *p; + const char *p; p = strrchr(fname, '.'); if (!p) { return false; diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index 432716130c6..00ccb9a881e 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -147,7 +147,7 @@ static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx, { const char *base1, *base2; const char *ext1, *ext2; - char *p; + const char *p = NULL; /* break into base part plus extension */ p = strrchr_m(fname, '.'); diff --git a/source4/ntvfs/posix/pvfs_shortname.c b/source4/ntvfs/posix/pvfs_shortname.c index 9e3cf5f4887..1061e3fb5c9 100644 --- a/source4/ntvfs/posix/pvfs_shortname.c +++ b/source4/ntvfs/posix/pvfs_shortname.c @@ -253,7 +253,7 @@ static bool is_8_3(struct pvfs_mangle_context *ctx, const char *name, bool check_case, bool allow_wildcards) { int len, i; - char *dot_p; + const char *dot_p; /* as a special case, the names '.' and '..' are allowable 8.3 names */ if (name[0] == '.') { @@ -424,7 +424,7 @@ static bool is_legal_name(struct pvfs_mangle_context *ctx, const char *name) static char *name_map(struct pvfs_mangle_context *ctx, const char *name, bool need83, bool cache83) { - char *dot_p; + const char *dot_p; char lead_chars[7]; char extension[4]; unsigned int extension_length, i; diff --git a/source4/ntvfs/posix/pvfs_sys.c b/source4/ntvfs/posix/pvfs_sys.c index 32770c1b1aa..1e0f39276e0 100644 --- a/source4/ntvfs/posix/pvfs_sys.c +++ b/source4/ntvfs/posix/pvfs_sys.c @@ -157,7 +157,8 @@ static struct pvfs_sys_ctx *pvfs_sys_pushdir(struct pvfs_state *pvfs, const char **pathname) { struct pvfs_sys_ctx *ctx; - char *cwd, *p, *dirname; + char *cwd, *dirname; + const char *p; int ret; ctx = talloc_zero(pvfs, struct pvfs_sys_ctx); diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 8375def4d10..b0325c12ba6 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -206,7 +206,7 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, } if (strncmp(sharename, "\\\\", 2) == 0) { - char *p = strchr(sharename+2, '\\'); + const char *p = strchr(sharename+2, '\\'); if (p) { sharename = p + 1; } diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c index fd323118118..880a5543e0b 100644 --- a/source4/ntvfs/simple/svfs_util.c +++ b/source4/ntvfs/simple/svfs_util.c @@ -58,7 +58,7 @@ char *svfs_unix_path(struct ntvfs_module_context *ntvfs, */ struct svfs_dir *svfs_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request *req, const char *unix_path) { - char *p, *mask; + const char *p, *mask; struct svfs_dir *dir; DIR *odir; struct dirent *dent; diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index 6df1c7703ed..d9b9b46c3f0 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -71,7 +71,7 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, } if (strncmp(sharename, "\\\\", 2) == 0) { - char *p2 = strchr(sharename+2, '\\'); + const char *p2 = strchr(sharename+2, '\\'); if (p2) { sharename = p2 + 1; } diff --git a/source4/rpc_server/lsa/lsa_lookup.c b/source4/rpc_server/lsa/lsa_lookup.c index a5d62726a86..cb882c2ee7a 100644 --- a/source4/rpc_server/lsa/lsa_lookup.c +++ b/source4/rpc_server/lsa/lsa_lookup.c @@ -975,7 +975,7 @@ static NTSTATUS dcesrv_lsa_LookupNames_base_call(struct dcesrv_lsa_LookupNames_b for (i=0;iin.num_names;i++) { struct dcesrv_lsa_TranslatedItem *item = &state->items[i]; - char *p = NULL; + const char *p = NULL; item->type = SID_NAME_UNKNOWN; item->name = r->in.names[i].string; diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index eb1874c4d51..ce960233f77 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -118,7 +118,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, /* the service might be of the form \\SERVER\SHARE. Should we put the server name we get from this somewhere? */ if (strncmp(service, "\\\\", 2) == 0) { - char *p = strchr(service+2, '\\'); + const char *p = strchr(service+2, '\\'); if (p) { service = p + 1; } diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c index ef97861df58..56c965ab230 100644 --- a/source4/torture/raw/qfileinfo.c +++ b/source4/torture/raw/qfileinfo.c @@ -808,7 +808,7 @@ static bool torture_raw_qfileinfo_internals(struct torture_context *torture, torture_fail(torture, "ALL_INFO didn't give a filename"); } if (s1 && s1->all_info.out.fname.s) { - char *p = strrchr(s1->all_info.out.fname.s, '\\'); + const char *p = strrchr(s1->all_info.out.fname.s, '\\'); if (!p) { printf("Not a full path in all_info/fname? - '%s'\n", s1->all_info.out.fname.s); diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 0bfbca4fe23..113a302e136 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -4746,7 +4746,7 @@ static bool test_winreg_symbolic_link(struct torture_context *tctx, static const char *strip_unc(const char *unc) { - char *name; + const char *name; if (!unc) { return NULL; @@ -5053,7 +5053,7 @@ static bool test_GetPrinterDriver2_level(struct torture_context *tctx, static const char *strip_path(const char *path) { - char *p; + const char *p; if (path == NULL) { return NULL; @@ -5568,7 +5568,7 @@ static bool test_SetPrinterDataEx_values(struct torture_context *tctx, if (torture_setting_bool(tctx, "samba3", false) || torture_setting_bool(tctx, "samba4", false)) { - char *q; + const char *q; q = strrchr(values[i], ','); if (q) { torture_comment( @@ -7180,7 +7180,7 @@ static const char *get_full_printername(struct torture_context *tctx, const char *name) { const char *full_name = talloc_strdup(tctx, name); - char *p; + const char *p; if (name && name[0] == '\\' && name[1] == '\\') { name += 2; @@ -8027,7 +8027,7 @@ static bool compose_local_driver_directory(struct torture_context *tctx, const char *local_dir, const char **path) { - char *p; + const char *p; p = strrchr(local_dir, '/'); if (!p) { @@ -10623,7 +10623,7 @@ static bool fillup_printserver_info(struct torture_context *tctx, static const char *driver_directory_dir(const char *driver_directory) { - char *p; + const char *p; p = strrchr(driver_directory, '\\'); if (p) { diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c index b055e164c1a..12ddb7ebd0e 100644 --- a/source4/torture/winbind/struct_based.c +++ b/source4/torture/winbind/struct_based.c @@ -809,7 +809,7 @@ static bool parse_domain_user(struct torture_context *torture, const char *domuser, fstring domain, fstring user) { - char *p = strchr(domuser, winbind_separator(torture)); + const char *p = strchr(domuser, winbind_separator(torture)); char *dom = NULL; if (!p) { diff --git a/source4/utils/oLschema2ldif/lib.c b/source4/utils/oLschema2ldif/lib.c index aefe8f96c71..529ac94ca6e 100644 --- a/source4/utils/oLschema2ldif/lib.c +++ b/source4/utils/oLschema2ldif/lib.c @@ -64,7 +64,7 @@ struct schema_token { static int check_braces(const char *string) { size_t b; - char *c; + const char *c; b = 0; if ((c = strchr(string, '(')) == NULL) {