size_t len = strlen(env);
if (len > 0 && len <= 1024) {
- char *p = NULL;
+ const char *p = NULL;
(void)cli_credentials_parse_string(cred,
env,
CRED_GUESS_ENV);
- if ((p = strchr_m(env, '%'))) {
- memset(p, '\0', strlen(cred->password));
+ p = strchr_m(env, '%');
+ if (p != NULL) {
+ memset(discard_const_p(char, p),
+ '\0',
+ strlen(cred->password));
}
}
}
debugstr = "set attributes";
do_set:
- if ((p = strchr(the_acl, ':')) == NULL)
+ if ((p = (char *)(uintptr_t)strchr(the_acl, ':')) == NULL)
{
printf("Missing value. ACL must be name:value pair\n");
return 1;
return NT_STATUS_NO_MEMORY;
}
- p = strchr_m(s, ':');
+ p = discard_const_p(char, strchr_m(s, ':'));
if (p == NULL) {
return NT_STATUS_NO_MEMORY;
}
return NT_STATUS_INVALID_PARAMETER;
}
- p = strchr_m(keys[0], ':');
+ p = discard_const_p(char, strchr_m(keys[0], ':'));
if (p == NULL) {
return NT_STATUS_NO_MEMORY;
}
file++;
}
- p = strchr_m(file, ',');
+ p = discard_const_p(char, strchr_m(file, ','));
if (p != NULL) {
*p = '\0';
}
return NT_STATUS_NO_MEMORY;
}
- p = strchr_m(s, ':');
+ p = discard_const_p(char, strchr_m(s, ':'));
if (p == NULL) {
return NT_STATUS_DRIVER_INTERNAL_ERROR;
}
status = gp_inifile_enum_section(ctx, str, &num_keys, &keys, &values);
if (NT_STATUS_IS_OK(status)) {
for (i = 0; i < num_keys; i++) {
- p = strchr_m(keys[i], ':');
+ p = discard_const_p(char, strchr_m(keys[i], ':'));
if (p == NULL) {
return NT_STATUS_INVALID_PARAMETER;
}
if (NT_STATUS_IS_OK(status)) {
s = get_string_unquote(s);
- p = strchr_m(s, ',');
+ p = discard_const_p(char, strchr_m(s, ','));
if (p == NULL) {
return NT_STATUS_INVALID_PARAMETER;
}
return NT_STATUS_NO_MEMORY;
}
- p = strchr_m(str, ',');
+ p = discard_const_p(char, strchr_m(str, ','));
if (p) {
*p = '\0';
p++;
/* Interactive mode */
while ((cmdname = tdb_getline("tdb> "))) {
arg2 = arg1 = NULL;
- if ((arg1 = strchr((const char *)cmdname,' ')) != NULL) {
+ if ((arg1 = strchr(discard_const_p(char, cmdname),' ')) != NULL) {
arg1++;
arg2 = arg1;
while (*arg2) {
/* characters below 0x3F are guaranteed to not appear in
non-initial position in multi-byte charsets */
if ((c & 0xC0) == 0) {
- return strchr(src, c);
+ s = strchr(src, c);
+ return discard_const_p(char, s);
}
/* this is quite a common operation, so we want it to be
/* characters below 0x3F are guaranteed to not appear in
non-initial position in multi-byte charsets */
if ((c & 0xC0) == 0) {
- return strrchr(s, c);
+ const char *t = strrchr(s, c);
+ return discard_const_p(char, t);
}
/* this is quite a common operation, so we want it to be
*/
_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct nbt_name *r)
{
- uint8_t *scope;
+ char *scope;
char *cname;
const char *s;
bool ok;
}
NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &s));
+ cname = discard_const_p(char, s);
- scope = (uint8_t *)strchr(s, '.');
+ scope = strchr(cname, '.');
if (scope) {
*scope = 0;
- r->scope = talloc_strdup(ndr->current_mem_ctx, (const char *)&scope[1]);
+ r->scope = talloc_strdup(ndr->current_mem_ctx, &scope[1]);
NDR_ERR_HAVE_NO_MEMORY(r->scope);
} else {
r->scope = NULL;
}
- cname = discard_const_p(char, s);
-
/* the first component is limited to 16 bytes in the DOS charset,
which is 32 in the 'compressed' form */
if (strlen(cname) > 32) {
const char *user;
char *c;
- c = strchr_m(users[i], separator);
+ c = discard_const_p(char, strchr_m(users[i], separator));
if (c == NULL) {
/*
const char *group;
char *c;
- c = strchr_m(groups[i], separator);
+ c = discard_const_p(char, strchr_m(groups[i], separator));
if (c == NULL) {
/*
struct wbcDomainSid **_sids)
{
uint32_t i;
- const char *s;
+ char *s = NULL;
struct winbindd_request request;
struct winbindd_response response;
struct wbcDomainSid *sids = NULL;
NULL);
BAIL_ON_PTR_ERROR(sids, wbc_status);
- s = (const char *)response.extra_data.data;
+ s = (char *)response.extra_data.data;
for (i = 0; i < response.data.num_entries; i++) {
char *n = strchr(s, '\n');
if (n) {
uint32_t *num_alias_rids)
{
uint32_t i;
- const char *s;
+ char *s = NULL;
struct winbindd_request request;
struct winbindd_response response;
ssize_t extra_data_len = 0;
sizeof(uint32_t), NULL);
BAIL_ON_PTR_ERROR(rids, wbc_status);
- s = (const char *)response.extra_data.data;
+ s = (char *)response.extra_data.data;
for (i = 0; i < response.data.num_entries; i++) {
char *n = strchr(s, '\n');
if (n) {
struct winbindd_response response;
uint32_t num_users = 0;
const char **users = NULL;
- const char *next;
+ char *next = NULL;
/* Initialise request */
/* Look through extra data */
- next = (const char *)response.extra_data.data;
+ next = (char *)response.extra_data.data;
while (next) {
- const char *current;
- char *k;
+ char *current = NULL;
+ char *k = NULL;
if (num_users >= response.data.num_entries) {
wbc_status = WBC_ERR_INVALID_RESPONSE;
struct winbindd_response response;
uint32_t num_groups = 0;
const char **groups = NULL;
- const char *next;
+ char *next = NULL;
/* Initialise request */
/* Look through extra data */
- next = (const char *)response.extra_data.data;
+ next = (char *)response.extra_data.data;
while (next) {
- const char *current;
- char *k;
+ char *current = NULL;
+ char *k = NULL;
if (num_groups >= response.data.num_entries) {
wbc_status = WBC_ERR_INVALID_RESPONSE;
return NULL;
}
- p = strchr_m( username, *lp_winbind_separator() );
+ p = discard_const_p(char, strchr_m(username, *lp_winbind_separator()));
/* code for a DOMAIN\user string */
char *p = NULL;
if ((p = strchr(puser,'%'))) {
+ const char *cp = NULL;
size_t len;
*p = 0;
libnetapi_set_username(ctx, puser);
libnetapi_set_password(ctx, p+1);
len = strlen(p+1);
- memset(strchr(arg,'%')+1,'X',len);
+ cp = strchr(arg, '%');
+ p = (char *)(uintptr_t)(const void *)cp;
+ memset(p+1,'X',len);
} else {
libnetapi_set_username(ctx, puser);
}
char *p = NULL;
if ((p = strchr(puser,'%'))) {
+ const char *cp = NULL;
size_t len;
*p = 0;
libnetapi_set_username(ctx, puser);
libnetapi_set_password(ctx, p+1);
len = strlen(p+1);
- memset(strchr(arg,'%')+1,'X',len);
+ cp = strchr(arg, '%');
+ p = (char *)(uintptr_t)(const void *)cp;
+ memset(p+1,'X',len);
} else {
libnetapi_set_username(ctx, puser);
}
return ADS_SUCCESS;
}
- vals = strchr_m(option, '=');
+ vals = discard_const_p(char, strchr_m(option, '='));
if (vals != NULL) {
*vals = 0;
vals++;
}
result->port = -1;
- tmp = strchr_m(result->serviceclass, '/');
+ tmp = discard_const_p(char, strchr_m(result->serviceclass, '/'));
if (tmp == NULL) {
/* illegal */
DBG_ERR("Failed to parse spn %s, no host definition\n",
p += 2; /* Skip the double slash */
/* See if any options were specified */
- if ((q = strrchr_m(p, '?')) != NULL ) {
+ q = discard_const_p(char, strrchr_m(p, '?'));
+ if (q != NULL) {
/* There are options. Null terminate here and point to them */
*q++ = '\0';
*/
/* check that '@' occurs before '/', if '/' exists at all */
- q = strchr_m(p, '@');
- r = strchr_m(p, '/');
+ q = discard_const_p(char, strchr_m(p, '@'));
+ r = discard_const_p(char, strchr_m(p, '/'));
if (q && (!r || q < r)) {
char *userinfo = NULL;
const char *u;
/* migrate printerdata */
for (j = 0; j < r.count; j++) {
char *valuename;
- const char *keyname;
+ char *keyname;
if (r.printer_data[j].type == REG_NONE) {
continue;
}
- keyname = r.printer_data[j].name;
+ keyname = discard_const_p(char, r.printer_data[j].name);
valuename = strchr(keyname, '\\');
if (valuename == NULL) {
continue;
if ((os = strstr(ippGetString(attr, 0, NULL),
NOVELL_SERVER_SYSNAME)) != NULL) {
os += strlen(NOVELL_SERVER_SYSNAME);
- if ((temp = strchr(os,'<')) != NULL)
+ temp = discard_const_p(char, os);
+ if ((temp = strchr(temp,'<')) != NULL)
*temp = '\0';
if (strcmp(os,NOVELL_SERVER_SYSNAME_NETWARE))
osFlag = 1; /* 1 for non-NetWare systems */
return NT_STATUS_INVALID_PARAMETER;
}
- s = strstr_m(unc, "\\\\");
+ s = discard_const_p(char, strstr_m(unc, "\\\\"));
if (s == NULL) {
return NT_STATUS_INVALID_PARAMETER;
}
/* just parse the service name from the device path and then
lookup the display name */
- if ( !(ptr = strrchr_m( r->in.devicepath, '\\' )) )
+ ptr = discard_const_p(char, strrchr_m(r->in.devicepath, '\\'));
+ if (ptr == NULL) {
return WERR_GEN_FAILURE;
+ }
*ptr = '\0';
- if ( !(ptr = strrchr_m( r->in.devicepath, '_' )) )
+ ptr = discard_const_p(char, strrchr_m(r->in.devicepath, '_'));
+ if (ptr == NULL) {
return WERR_GEN_FAILURE;
+ }
ptr++;
mem_ctx = talloc_stackframe();
return NULL;
}
- name = strchr_m(line, ' ');
+ name = discard_const_p(char, strchr_m(line, ' '));
if (name == NULL) {
return NULL;
}
aprinter = discard_const_p(char, handlename);
if ( *handlename == '\\' ) {
servername = canon_servername(handlename);
- if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
+ aprinter = discard_const_p(char, strchr_m(servername, '\\'));
+ if (aprinter != NULL) {
*aprinter = '\0';
aprinter++;
}
/* check for OID in valuename */
- oid_string = strchr_m(r->in.value_name, ',');
+ oid_string = discard_const_p(char, strchr_m(r->in.value_name, ','));
if (oid_string) {
*oid_string = '\0';
oid_string++;
TDB_DATA data_val;
char mangled_name_key[13];
char *s1 = NULL;
- char *s2 = NULL;
+ const char *s2 = NULL;
+ char *tmp_non_const_dot = NULL;
/* If the cache isn't initialized, give up. */
if( !tdb_mangled_cache )
* put it back once we've used it.
* JRA
*/
- *s2 = '\0';
+ tmp_non_const_dot = discard_const_p(char, s2);
+ *tmp_non_const_dot = '\0';
}
}
DEBUG(5,("cache_mangled_name: Stored entry %s -> %s\n", mangled_name_key, raw_name));
}
/* Restore the change we made to the const string. */
- if (s2) {
- *s2 = '.';
+ if (tmp_non_const_dot != NULL) {
+ *tmp_non_const_dot = '.';
}
}
char *pathname_local = NULL;
char *p = NULL;
const char *hostname = NULL;
- const char *servicename = NULL;
+ char *servicename = NULL;
const char *reqpath = NULL;
bool my_hostname = false;
NTSTATUS status;
DEBUG(10, ("split_ntfs_stream_name called for [%s]\n", fname));
- sname = strchr_m(fname, ':');
+ sname = discard_const_p(char, strchr_m(fname, ':'));
if (sname == NULL) {
if (pbase != NULL) {
if (argc == 0)
return net_lookup_usage(c, argc, argv);
- p = strchr_m(name,'#');
+ p = discard_const_p(char, strchr_m(name, '#'));
if (p) {
*p = '\0';
sscanf(++p,"%x",&name_type);
fstrcpy(result[i].name, users[i]);
- p = strchr_m(users[i], *lp_winbind_separator());
+ p = discard_const_p(char, strchr_m(users[i], *lp_winbind_separator()));
DEBUG(3, ("%s\n", users[i]));
for (i = 0; ids[i]; i++) {
struct passwd *pw;
struct group *gr;
- const char *name;
+ char *name;
struct dom_sid sid;
enum lsa_SidType type;
DEBUG(10,("Converting %s\n", (const char *)key.dptr));
- p = strchr((const char *)key.dptr, '/');
+ p = strchr((char *)key.dptr, '/');
if (!p)
return 0;
DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
- if (query_host && (p=strchr_m(query_host,'#'))) {
- *p = 0;
- p++;
- sscanf(p, "%x", &name_type);
+ if (query_host) {
+ p = discard_const_p(char, strchr_m(query_host, '#'));
+ if (p) {
+ *p = 0;
+ p++;
+ sscanf(p, "%x", &name_type);
+ }
}
if (query_host) {
{
const char *sam_ldb_path = NULL;
- const char *private_dir = NULL;
+ char *private_dir = NULL;
char *p = NULL;
return;
}
- p = strchr_m(token, ';');
+ p = discard_const_p(char, strchr_m(token, ';'));
if (p != NULL) {
/*
* skip smbd-specific extra data:
}
/* maybe it is a DNS name */
- p = strchr_m(token,'/');
+ p = discard_const_p(char, strchr_m(token, '/'));
if (p == NULL) {
if (!interpret_string_addr(&ss, token, 0)) {
DEBUG(2, ("interpret_interface: Can't find address "
address = (char *)val->data;
- p = strchr_m(address, ';');
+ p = discard_const_p(char, strchr_m(address, ';'));
if (!p) {
/* support old entries, with only the address */
addr->address = (const char *)talloc_steal(addr, val->data);
goto failed;
}
wins_owner = p + 10;
- p = strchr_m(wins_owner, ';');
+ p = discard_const_p(char, strchr_m(wins_owner, ';'));
if (!p) {
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
goto failed;
}
expire_time = p + 11;
- p = strchr_m(expire_time, ';');
+ p = discard_const_p(char, strchr_m(expire_time, ';'));
if (!p) {
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
goto failed;
char *delim;
char *full_name = discard_const_p(char, name);
- delim = strrchr(name, '/');
+ delim = strrchr(full_name, '/');
if (!delim) {
talloc_free(lck);
return NT_STATUS_INTERNAL_ERROR;
if (test_data->upn) {
char *p;
test_data->username = talloc_strdup(test_data, upn);
- p = strchr_m(test_data->username, '@');
+ p = discard_const_p(char, strchr_m(test_data->username, '@'));
if (p) {
*p = '\0';
p++;
if (test_data->removedollar) {
char *p;
- p = strchr_m(test_data->username, '$');
+ p = discard_const_p(char, strchr_m(test_data->username, '$'));
torture_assert(tctx, p != NULL, talloc_asprintf(tctx,
"username[%s] contains no '$'\n",
test_data->username));
if (test_data->upn) {
char *p;
test_data->username = talloc_strdup(test_data, upn);
- p = strchr(test_data->username, '@');
+ p = discard_const_p(char, strchr(test_data->username, '@'));
if (p) {
*p = '\0';
p++;
if (test_data->removedollar) {
char *p;
- p = strchr_m(test_data->username, '$');
+ p = discard_const_p(char, strchr_m(test_data->username, '$'));
torture_assert(tctx, p != NULL, talloc_asprintf(tctx,
"username[%s] contains no '$'\n",
test_data->username));
for (i=0; i < ARRAY_SIZE(keys); i++) {
char *c;
- const char *key;
+ char *key;
enum winreg_Type type;
DATA_BLOB blob_in, blob_out;
const char **subkeys;
char *p, *d;
/* retrieve the userdn */
- p = strchr_m(dns, '#');
+ p = discard_const_p(char, strchr_m(dns, '#'));
if (!p) {
lpcfg_set_cmdline(lp_ctx, "torture:ldap_userdn", "");
lpcfg_set_cmdline(lp_ctx, "torture:ldap_basedn", "");