]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
C26: const-qualify variables for read-only strchr/strrchr/strstr results
authorStefan Metzmacher <metze@samba.org>
Mon, 30 Mar 2026 15:17:47 +0000 (17:17 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 21 May 2026 17:25:33 +0000 (17:25 +0000)
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 <asn@samba.org>

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16006

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
65 files changed:
ctdb/protocol/protocol_util.c
lib/addns/dnsquery_srv.c
lib/cmdline/cmdline.c
lib/ldb/common/ldb_ldif.c
lib/ldb/common/ldb_modules.c
lib/tdb/tools/tdbtool.c
lib/util/base64.c
lib/util/dns_cmp.c
lib/util/smb_strtox.c
lib/util/util_net.c
libcli/auth/netlogon_creds_cli.c
libcli/nbt/tools/nmblookup.c
libcli/security/tests/test_sddl_conditional_ace.c
nsswitch/pam_winbind.c
nsswitch/wbinfo.c
source3/auth/auth_generic.c
source3/auth/user_krb5.c
source3/lib/util.c
source3/libsmb/cli_smb2_fnum.c
source3/libsmb/cliconnect.c
source3/modules/nfs4acl_xattr_nfs.c
source3/modules/vfs_fruit.c
source3/modules/vfs_media_harmony.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_unityed_media.c
source3/modules/vfs_virusfilter.c
source3/param/util.c
source3/passdb/lookup_sid.c
source3/printing/print_iprint.c
source3/smbd/filename.c
source3/smbd/mangle_hash.c
source3/smbd/mangle_hash2.c
source3/smbd/smb1_lanman.c
source3/smbd/smb1_reply.c
source3/utils/net_ads.c
source3/utils/net_vfs.c
source3/utils/ntlm_auth.c
source3/utils/sharesec.c
source3/utils/testparm.c
source3/winbindd/nss_info.c
source3/winbindd/winbindd_pam.c
source3/winbindd/winbindd_util.c
source4/dsdb/common/util_trusts.c
source4/dsdb/samdb/ldb_modules/partition_init.c
source4/dsdb/samdb/ldb_modules/ranged_results.c
source4/dsdb/samdb/ldb_modules/rootdse.c
source4/dsdb/samdb/ldb_modules/samldb.c
source4/lib/registry/util.c
source4/lib/socket/socket_ip.c
source4/ntvfs/cifs/vfs_cifs.c
source4/ntvfs/ipc/vfs_ipc.c
source4/ntvfs/ntvfs_generic.c
source4/ntvfs/posix/pvfs_rename.c
source4/ntvfs/posix/pvfs_shortname.c
source4/ntvfs/posix/pvfs_sys.c
source4/ntvfs/posix/vfs_posix.c
source4/ntvfs/simple/svfs_util.c
source4/ntvfs/simple/vfs_simple.c
source4/rpc_server/lsa/lsa_lookup.c
source4/smb_server/smb/service.c
source4/torture/raw/qfileinfo.c
source4/torture/rpc/spoolss.c
source4/torture/winbind/struct_based.c
source4/utils/oLschema2ldif/lib.c

index d8f12fa87ba1ad052e31d57690d3a3a0b8044df5..8365fc2e1fd4503f23e415b6e70fffdcaf4b9e6f 100644 (file)
@@ -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) {
index ac9e612b8f9fcf4c7c9d05aed2da6871f609fa4b..6c4f06dd898853488fce7995a6a37776edc6b332 100644 (file)
@@ -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;
 
                /*
index f96ca88f95b22850cbdfb27e6367299b765cef50..caedbd45bbd10698d71a255ae937c9fc5de28dcb 100644 (file)
@@ -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;
index 24a0bcdefa54c0bb1ea4bd2609d28608a884e0ac..b60ffe312a86bf7a742650cf52903eb67a42a62f 100644 (file)
@@ -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;
 
index 04f27e6918f8f44874cb8d4632721c8d6144de1d..0d11e0c4e9e8a4ce966a7c08121aae90f46f8968 100644 (file)
@@ -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) {
index 1f4c99a00ff759883991ceb752788cf986171559..6f2dcd19a0bd6f166d9de27a7614c5041bb7783b 100644 (file)
@@ -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);
index 7acc83d0eafe8e584bd2bc7b1f514a6cd174cb35..99fda0bfa3bb9da756fa9fd785dee45cc9af48bf 100644 (file)
@@ -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;
index e20c4297963889c479aa14d7234d197ff1f6071d..c9b8a7d64f89e33c017a899653f6de26abc0121d 100644 (file)
@@ -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;
index 7a477dc8aaae714e01e152ec954e78ad9044bc86..417140b512221d421d8d552552737299aa61a754 100644 (file)
@@ -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;
index e410cdf915a86ba60b0d2f14f20e857b39332cad..9ac91807b18881a2cf2dfaa9eb5a1643f7dbadac 100644 (file)
@@ -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;
index 879f79c5400730f258d94a8f13f846c1d3da9262..736c2f114ca92bbac2128af54793634c5af01170 100644 (file)
@@ -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;
 
index 6ca38faa863444c4ae1287d1b0ef369d17956735..75c6bed0b7ac4ac9b5b3248429e1d375dd1d5018 100644 (file)
@@ -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;
index fd2473a8fff4ff254a6d34334a108ba2b7c456cf..77538c90bf7ebd062157fc60bd9c17428584f8d0 100644 (file)
@@ -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);
index 1c2634bc80d8da6e4f22dafa5502e28caca74103..cb9edb4bc7b3aa5bff3cc11d7b798edf7cce58e7 100644 (file)
@@ -2328,7 +2328,7 @@ static const char *get_conf_item_string(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,
@@ -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,
index 2f040728723249e4a3e8c7adf40286cf49717b0f..9515749aa7b79ac6ab39a612845a0c497e212d03 100644 (file)
@@ -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? */
index a5cfd69c5067e54710e1b0d5e595c546c00c940e..e94ecef467dc6a25cb81ff427d36e6229d3d9781 100644 (file)
@@ -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;
 
        /*
index 169bf563368f61ae97f3bdf5e5a6d1a4a5e69254..10c98fcc161fb7ab16fd7995a28352887267e2f1 100644 (file)
@@ -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;
index 3308654d236bfab45fbe7714b233334d0696abb5..531af25dc27356e2613471c92a227e95552efae2 100644 (file)
@@ -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 */
index 6ab5d46f1587255f459e6d7841bb7817aace4e0c..d8eaa10a8dbc4374ad7009d1caf7f43f531f29d5 100644 (file)
@@ -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 */
index 0bcbf53287378aa4c357ee4a6f816322dd64a5be..78d147301540d135e1588948c18c868ea2bc0780 100644 (file)
@@ -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);
index bb2ceeee8640c389d27f1706aeb89f45215f12c0..6c35ac32827a278deea968a028b621b9f88c0f20 100644 (file)
@@ -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) {
index 8ac0ff346aec601306752885e1c918a756fb2673..f41b355a0ded199424e1025dc861ca8acb5d9a02 100644 (file)
@@ -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;
index 0fe872ea69bd38c1504c320926c6e35dc3b7976a..7e22ff8b2d5a2904a44ababbd786a101174c3b34 100644 (file)
@@ -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'
index 0c47f09268b9914b50d955480a254c98adddb4f0..62ceddcd19009745d5e6b91c1fff51df85453ece 100644 (file)
@@ -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 "
index 4d8b81bdc9d85a276fec26d70037f2c90e14f7ac..a8cc9cd10bde01994f376ee062334e3435d08d2c 100644 (file)
@@ -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;
 
index 84970998ff6dc98e8ff144becd9a1186e14565b1..63afbe4d928bfe5222903fc5da173b5b97ca63dd 100644 (file)
@@ -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;
index a6e167df12684f2435e1f5eb1e04287454f161f4..9f177b561294f88a243d5a6b12e7805930a2ed89 100644 (file)
@@ -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;
 
index 94036f0df2955e56715e4273de4ebd4b1e6bf079..d4aaee197866700468383b78b78148283ab83b87 100644 (file)
@@ -25,7 +25,7 @@
 **********************************************************/
 uint32_t get_int_param( const char* param )
 {
-       char *p;
+       const char *p = NULL;
 
        p = strchr( param, '=' );
        if ( !p )
index 61c67b7a809748ec3944d48b0418bc84777d0eb5..ba254f7ee09c6b1bef2815294961fb47ba2b1011 100644 (file)
@@ -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) {
index 2b2215eb8c3fc9ce5d01de880903dce7eb3420e8..52649d94e4b58a37d2befd81c29e99dd3004703b 100644 (file)
@@ -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 */
 
index cb3b7da45a1ad7ce49fd85469a6080cfd78740d2..1d3c4484479de67927c53ac835312722d1625a00 100644 (file)
@@ -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;
 
index 6a3cb33a5de5063fb3b6153ffa73e85c47e5a3ac..f3c87df97f757d7342ffe632712ec9f924f55fb6 100644 (file)
@@ -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);
index 0075d3bfcba4dab08f70d18197b032212602216e..fdedb7571da4ac894ee2bf24eb2896938f3911b2 100644 (file)
@@ -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;
index 8bcddcbb8c2e0d5f5dc7e2da1497eaace604cbb2..6e518d6cc30c4f971f9ee567c4fec583619b4c53 100644 (file)
@@ -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;
index 5aee828b496945601483a5e0b39a5e35f723e8c3..cd12dbc143b14a1cc67ab1cbd38bbc74ca3cbb7a 100644 (file)
@@ -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);
index 3048d95b5f2a4c40350d2f5aee25c406b237dd8f..91090d8857ee686d8fa7ff454b063573937f8b64 100644 (file)
@@ -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;
 
index f38650ae1c3f49fd948ad01de00415cb8a770b6e..6547ba1c89745821f6aff44d8e222488e500eb67 100644 (file)
@@ -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;
 
index d32a985098047f753141ac818218b98de938c13d..83756f6271b1c373a3c3f372492d6d1359201cf0 100644 (file)
@@ -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;
index ea7c56e65667993903c71dd928ae286d7ca4964b..02f886848772f0d1ddf53b09e96889b4845e7241 100644 (file)
@@ -68,7 +68,7 @@ static struct security_descriptor* parse_acl_string(TALLOC_CTX *mem_ctx, const c
                return NULL;
 
        for ( i=0; i<num_ace; i++ ) {
-               char *end_acl = strchr_m( pacl, ',' );
+               const char *end_acl = strchr_m( pacl, ',' );
                fstring acl_string;
 
                strncpy( acl_string, pacl, MIN( PTR_DIFF( end_acl, pacl ), sizeof(fstring)-1) );
index 14e6181f417f639c5ef46c8d9b57415d54a3ca4f..af3a253fc2880742bfc67a4c5249aa40696a388a 100644 (file)
@@ -876,8 +876,8 @@ static void do_per_share_checks(int s)
 
        if(deny_list) {
                for (i=0; deny_list[i]; i++) {
-                       char *hasstar = strchr_m(deny_list[i], '*');
-                       char *hasquery = strchr_m(deny_list[i], '?');
+                       const char *hasstar = strchr_m(deny_list[i], '*');
+                       const char *hasquery = strchr_m(deny_list[i], '?');
                        if(hasstar || hasquery) {
                                fprintf(stderr,
                                        "Invalid character %c in hosts deny list "
@@ -891,8 +891,8 @@ static void do_per_share_checks(int s)
 
        if(allow_list) {
                for (i=0; allow_list[i]; i++) {
-                       char *hasstar = strchr_m(allow_list[i], '*');
-                       char *hasquery = strchr_m(allow_list[i], '?');
+                       const char *hasstar = strchr_m(allow_list[i], '*');
+                       const char *hasquery = strchr_m(allow_list[i], '?');
                        if(hasstar || hasquery) {
                                fprintf(stderr,
                                        "Invalid character %c in hosts allow "
index 3b58ca2932414bb446d07ec3e97a0aa55e90419c..b5850c9269ee48e7e239c97bdd4ffda579654d97 100644 (file)
@@ -90,7 +90,7 @@ static bool parse_nss_parm(TALLOC_CTX *mem_ctx,
                           char **backend,
                           char **domain)
 {
-       char *p;
+       const char *p;
 
        *backend = *domain = NULL;
 
index c4a368222b26a99d0ba8ab175add35b7137a8023..f83bde98484b7b51a06306c3385194cc2872a816 100644 (file)
@@ -688,7 +688,7 @@ static bool generate_krb5_ccache(TALLOC_CTX *mem_ctx,
 
        /* Handle types with explicit paths and %u or %{uid} substitution */
        if (has_prefix) {
-               char *p;
+               const char *p;
                const char *subst_pattern = NULL;
 
                p = strchr(type, '%');
index bc2ad712fdbb7cc75245d858ae1d60b3083997dd..3c83f96837d5e9ba9018909884d8a0e06e53c375 100644 (file)
@@ -1990,7 +1990,7 @@ bool parse_domain_user(TALLOC_CTX *ctx,
                       char **pdomain,
                       char **puser)
 {
-       char *p = NULL;
+       const char *p = NULL;
        char *namespace = NULL;
        char *domain = NULL;
        char *user = NULL;
index 34ad72f85f1a528abadb8d85f8003f4492581baf..7aa33c1d1a5a777b2915dcd5377c91ebde020dc7 100644 (file)
@@ -1000,10 +1000,14 @@ NTSTATUS dsdb_trust_normalize_forest_info_step1(TALLOC_CTX *mem_ctx,
                        TALLOC_FREE(frame);
                        return NT_STATUS_INVALID_PARAMETER;
                }
-               p = strstr_m(ntln->string, "..");
-               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 &&
index 0c218e7f335230dadcd02169e473c20f3487ef34..01fb1756112f8108e5d47ec3414a88392d04a544 100644 (file)
@@ -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);
index b010abb8ab499820e1b57e38ba8793d744bbd859..6cb313773d6cb4c8d9eb046e3da89bb30c1a0641 100644 (file)
@@ -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);
index 7541a2cf3762babe0e6c53f637ec81b4bc1fbfcb..364c118c70d8a65f5a82a0009fe73295a3a100bc 100644 (file)
@@ -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;
 
index 99d183e14e520b1136d743e1497a72eb4aac48ea..d5c0efd8710cabf4da030184e113dd08dbac6fcc 100644 (file)
@@ -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;
index 1197adba7f15fdad160d2e4669419063f48cd99a..014da161f85809acfbe30708e9efbe92170f338f 100644 (file)
@@ -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;
index 62dbf1d2213431fbbbe63b13d8bff033a214c718..4c33fc4af0a3b334f0e5a3922fcd2c919c76999c 100644 (file)
@@ -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;
index a43f91070bdaa255a93f8a2916f1c5ae63320936..7fa9c948e1cfdb843eaee14f3ae21ec15d413cf9 100644 (file)
@@ -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;
                }
index 01e2a5deef492defacc656c006f301ad761f4191..452f13ee594508a1c1247c1ed84f5fe9eb2007a4 100644 (file)
@@ -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;
                }
index de0ae2ce8280363c4eaf7b4afe3d11b7e0078cfb..be05b11e978ca4cb543a802fbe8f05ce74b426b0 100644 (file)
@@ -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;
index 432716130c6c3ab4101097ca5de22512782dbe91..00ccb9a881ed990fa6fe796c7b3c7063ef7e1a42 100644 (file)
@@ -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, '.');
index 9e3cf5f488764e4a15fba584ac8708ace771cdc4..1061e3fb5c9d5587dba67fb4c8034bd60cfc5ccc 100644 (file)
@@ -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;
index 32770c1b1aa7e7af1bfd76d837b6b038f2fcb643..1e0f39276e0e245d5be7f98e6a60dffb092a00a4 100644 (file)
@@ -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);
index 8375def4d104574c8d9e208243db0772121d3d29..b0325c12ba6533da5f2eab919d75ac2094912c17 100644 (file)
@@ -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;
                }
index fd323118118436148004a5abc9cfa10db6c866a6..880a5543e0bb6ab60912e0b8e800d4dc405f1346 100644 (file)
@@ -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;
index 6df1c7703eddabc6a0de95bada9899fdeb19737b..d9b9b46c3f068f93fd404dcf3007a3d18f9c73d2 100644 (file)
@@ -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;
                }
index a5d62726a86a33ea2673ed028026dba10e114a72..cb882c2ee7a04af7a99a4ba1755c1c2cdb13a6ae 100644 (file)
@@ -975,7 +975,7 @@ static NTSTATUS dcesrv_lsa_LookupNames_base_call(struct dcesrv_lsa_LookupNames_b
 
        for (i=0;i<r->in.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;
index eb1874c4d510c68c7496943b955b2dc28860dc5f..ce960233f7718fbee70beebb894c4c1dac46c293 100644 (file)
@@ -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;
                }
index ef97861df58dd71aa3f74c7846ced837b5152515..56c965ab23072c8db0c657e641f4464c9331476c 100644 (file)
@@ -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);
index 0bfbca4fe23497ff9670a0c9ed9d55cdbe690457..113a302e136a2f66a377b8c086a500eb18d884fd 100644 (file)
@@ -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) {
index b055e164c1a0823f0ceaea3da71ce9ac209ae182..12ddb7ebd0e919bfa98f6ce6d607f2ec8c6c9e99 100644 (file)
@@ -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) {
index aefe8f96c71ebbf52369f631e591b6fe46605de2..529ac94ca6e3348fc73c8ed917d39e34f342e2ba 100644 (file)
@@ -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) {