{
register char *ret;
- if((ret = (char *) malloc((unsigned) strlen(sp)+1)) == NULL) {
+ if((ret = strdup(sp)) == NULL) {
fprintf(stderr, "no memory for saving args\n");
exit(1);
}
- (void) strcpy(ret,sp);
return(ret);
}
#endif
argc--, argv++;
if (argc == 0)
usage();
- if(!(krb_realm = (char *)malloc(strlen(*argv) + 1))){
+ if(!(krb_realm = strdup(*argv))){
fprintf(stderr, "rcp: Cannot malloc.\n");
exit(1);
}
- strcpy(krb_realm, *argv);
goto next_arg;
case 'c': /* Change default ccache file */
argc--, argv++;
if (argc == 0)
usage();
- if(!(krb_cache = (char *)malloc(strlen(*argv) + 1))){
+ if(!(krb_cache = strdup(*argv))){
fprintf(stderr, "rcp: Cannot malloc.\n");
exit(1);
}
- strcpy(krb_cache, *argv);
goto next_arg;
case 'C': /* Change default config file */
argc--, argv++;
if (argc == 0)
usage();
- if(!(krb_config = (char *)malloc(strlen(*argv) + 1))){
+ if(!(krb_config = strdup(*argv))){
fprintf(stderr, "rcp: Cannot malloc.\n");
exit(1);
}
- strcpy(krb_config, *argv);
goto next_arg;
case 'P':
if (!strcmp (*argv, "O"))
"rlogin: -k flag must be followed with a realm name.\n");
exit (1);
}
- if(!(krb_realm = (char *)malloc(strlen(*argv) + 1))){
+ if(!(krb_realm = strdup(*argv))){
fprintf(stderr, "rlogin: Cannot malloc.\n");
exit(1);
}
- strcpy(krb_realm, *argv);
argv++, argc--;
goto another;
}
fprintf(stderr, "rsh(kerberos): -k flag must have a realm after it.\n");
exit (1);
}
- if(!(krb_realm = (char *)malloc(strlen(*argv) + 1))){
+ if(!(krb_realm = strdup(*argv))){
fprintf(stderr, "rsh(kerberos): Cannot malloc.\n");
exit(1);
}
- strcpy(krb_realm, *argv);
argv++, argc--;
goto another;
}
struct stat s2;
int offst = 0;
- copy = malloc(strlen(cmdbuf) + 1);
+ copy = strdup(cmdbuf);
if (copy == NULL) {
perror("malloc");
_exit(1);
}
- strcpy(copy, cmdbuf);
if (do_encrypt && !strncmp(cmdbuf, "-x ", 3)) {
offst = 3;
}
{
register char *ret;
- if ((ret = (char *) malloc((unsigned) strlen(sp)+1)) == NULL) {
+ if ((ret = strdup(sp)) == NULL) {
fprintf(stderr, "no memory for saving args\n");
exit(1);
}
- (void) strcpy(ret,sp);
return(ret);
}
#endif
case LOGIN:
if (token()) {
if (*aname == 0) {
- *aname = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*aname, tokval);
+ *aname = strdup(tokval);
} else {
if (strcmp(*aname, tokval))
goto next;
goto bad;
}
if (token() && *apass == 0) {
- *apass = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*apass, tokval);
+ *apass = strdup(tokval);
}
break;
case ACCOUNT:
goto bad;
}
if (token() && *aacct == 0) {
- *aacct = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*aacct, tokval);
+ *aacct = strdup(tokval);
}
break;
case MACDEF:
{
char *p;
- p = malloc((unsigned) strlen(s) + 1);
+ p = strdup(s);
if (p == NULL)
fatal("Ran out of memory.");
- (void) strcpy(p, s);
return (p);
}
sgetsave(s)
char *s;
{
- char *new = malloc((unsigned) strlen(s) + 1);
+ char *new = strdup(s);
if (new == NULL) {
perror_reply(421, "Local resource failure: malloc");
dologout(1);
/* NOTREACHED */
}
- (void) strcpy(new, s);
return (new);
}
rdata.magic = 0;
rdata.length = strlen(telnet_krb5_realm);
- rdata.data = (char *) malloc(rdata.length + 1);
+ rdata.data = strdup(telnet_krb5_realm);
if (rdata.data == NULL) {
fprintf(stderr, "malloc failed\n");
return(0);
}
- strcpy(rdata.data, telnet_krb5_realm);
krb5_princ_set_realm(telnet_context, creds.server, &rdata);
}
}
if (!err) {
- string->data = malloc (strlen (in_cstring) + 1);
- if (string->data) {
- strcpy ((char *)string->data, in_cstring);
- } else {
+ string->data = strdup (in_cstring);
+ if (!string->data) {
err = cci_check_error (ccErrNoMem);
}
goto done;
} else {
if(strcmp(cp, "")) {
- if((rec->policy = (char *) malloc(strlen(cp)+1)) == NULL) {
+ if((rec->policy = strdup(cp)) == NULL) {
ret = ENOMEM;
goto done;
}
- strcpy(rec->policy, cp);
} else rec->policy = NULL;
}
if((cp = nstrtok((char *) NULL, "\t")) == NULL) {
retcode = TCL_ERROR;
goto finished;
}
- tl->tl_data_contents = (krb5_octet *) malloc(tmp+1);
- strcpy((char *) tl->tl_data_contents, argv1[2]);
+ tl->tl_data_contents = (krb5_octet *) strdup(argv1[2]);
Tcl_Free((char *) argv1);
argv1 = NULL;
errpkt.server = request->server;
errpkt.client = request->client;
errpkt.text.length = strlen(status)+1;
- if (!(errpkt.text.data = malloc(errpkt.text.length)))
+ if (!(errpkt.text.data = strdup(status)))
return ENOMEM;
- (void) strcpy(errpkt.text.data, status);
if (!(scratch = (krb5_data *)malloc(sizeof(*scratch)))) {
free(errpkt.text.data);
else
errpkt.client = 0;
errpkt.text.length = strlen(status) + 1;
- if (!(errpkt.text.data = malloc(errpkt.text.length)))
+ if (!(errpkt.text.data = strdup(status)))
return ENOMEM;
- (void) strcpy(errpkt.text.data, status);
if (!(scratch = (krb5_data *)malloc(sizeof(*scratch)))) {
free(errpkt.text.data);
xfree(haddr);
- if ((canon = (char *) xmalloc(strlen(hent->h_name)+1)) == NULL)
+ if ((canon = (char *) strdup(hent->h_name)) == NULL)
return(NULL);
- strcpy(canon, hent->h_name);
-
for (str = canon; *str; str++)
if (isupper(*str)) *str = tolower(*str);
buf[sizeof(buf)-1] = '\0';
- if (! (ptr = xmalloc(strlen(buf) + 1)))
- return 0;
-
- return strcpy(ptr, buf);
+ return strdup(buf);
}
krb5_error_code kerr;
if (name) {
- new_name = malloc(strlen(name) + 1);
+ new_name = strdup(name);
if (new_name == NULL) {
*minor_status = ENOMEM;
return GSS_S_FAILURE;
}
- strcpy(new_name, name);
}
kg_ccache_name = k5_getspecific(K5_KEY_GSS_KRB5_CCACHE_NAME);
/* now copy the status code and return to caller */
outStr->length = strlen(errStr);
- outStr->value = malloc((size_t)outStr->length+1);
+ outStr->value = strdup(errStr);
if (outStr->value == NULL) {
outStr->length = 0;
return (GSS_S_FAILURE);
}
- (void) strcpy((char *)outStr->value, errStr);
return (GSS_S_COMPLETE);
} /* displayMajor */
static spnego_token_t
make_spnego_token(char *name)
{
- spnego_token_t token;
-
- token = (spnego_token_t)malloc(strlen(name)+1);
-
- if (token == NULL)
- return (NULL);
- strcpy(token, name);
- return (token);
+ return (spnego_token_t)strdup(name);
}
static gss_buffer_desc
log_control.log_nentries = 1;
}
if (log_control.log_nentries) {
- log_control.log_whoami = (char *) malloc(strlen(whoami)+1);
- if (log_control.log_whoami)
- strcpy(log_control.log_whoami, whoami);
-
+ log_control.log_whoami = strdup(whoami);
log_control.log_hostname = (char *) malloc(MAXHOSTNAMELEN + 1);
if (log_control.log_hostname) {
gethostname(log_control.log_hostname, MAXHOSTNAMELEN);
}
}
if (opok) {
- acle->ae_name = (char *) malloc(strlen(acle_principal)+1);
+ acle->ae_name = strdup(acle_principal);
if (acle->ae_name) {
- strcpy(acle->ae_name, acle_principal);
acle->ae_principal = (krb5_principal) NULL;
acle->ae_name_bad = 0;
DPRINT(DEBUG_ACL, acl_debug_level,
if( cnt != 1 )
return KADM5_UNK_POLICY;
- if ((entry->policy = (char *) malloc(strlen(t->name) + 1)) == NULL) {
+ if ((entry->policy = strdup(t->name)) == NULL) {
krb5_db_free_policy(handle->context, t);
return ENOMEM;
}
- strcpy(entry->policy, t->name);
entry->pw_min_life = t->pw_min_life;
entry->pw_max_life = t->pw_max_life;
entry->pw_min_length = t->pw_min_length;
if ((mask & KADM5_POLICY) &&
adb.policy && (adb.aux_attributes & KADM5_POLICY)) {
- if ((entry->policy = (char *) malloc(strlen(adb.policy) + 1)) == NULL) {
+ if ((entry->policy = strdup(adb.policy)) == NULL) {
ret = ENOMEM;
goto done;
}
- strcpy(entry->policy, adb.policy);
}
if (mask & KADM5_AUX_ATTRIBUTES)
{
free(*s);
if (buf == NULL) {
- *s = malloc(sizeof("<NULL>"));
+ *s = strdup("<NULL>");
if (*s == NULL) return ENOMEM;
- strcpy(*s,"<NULL>");
} else if (buf->base == NULL) {
- *s = malloc(sizeof("<EMPTY>"));
+ *s = strdup("<EMPTY>");
if (*s == NULL) return ENOMEM;
- strcpy(*s,"<EMPTY>");
} else {
unsigned int length = asn1buf_len(buf);
unsigned int i;
free(*s);
if (buf == NULL) {
- *s = malloc(sizeof("<NULL>"));
+ *s = strdup("<NULL>");
if (*s == NULL) return ENOMEM;
- strcpy(*s,"<NULL>");
} else if (buf->base == NULL) {
- *s = malloc(sizeof("<EMPTY>"));
+ *s = strdup("<EMPTY>");
if (*s == NULL) return ENOMEM;
- strcpy(*s,"<EMPTY>");
} else {
unsigned int length = asn1buf_len(buf);
int i;
return err;
}
- d->name = malloc(strlen(name) + 1);
+ d->name = strdup(name);
if (d->name == NULL) {
k5_cc_mutex_destroy(&d->lock);
krb5_xfree(d);
d->changetime = 0;
update_mcc_change_time(d);
- /* Set up the filename */
- strcpy(d->name, name);
-
n = malloc(sizeof(krb5_mcc_list_node));
if (n == NULL) {
free(d->name);
}
if (!err) {
- name = (char *) malloc (sizeof (*name) * (strlen (ccstring->data) + 1));
+ name = strdup (ccstring->data);
if (!name) { err = KRB5_CC_NOMEM; }
}
if (!err) {
- strcpy (name, ccstring->data);
ccapi_data->cache_name = name;
name = NULL; /* take ownership */
}
if (!err) {
- name = malloc (strlen(residual) + 1);
+ name = strdup (residual);
if (!name) { err = KRB5_CC_NOMEM; }
}
}
if (!err) {
- strcpy(name, residual);
ccapi_data->cache_name = name;
name = NULL; /* take ownership */
}
if (!err) {
- name = (char *) malloc (sizeof (*name) * (strlen (ccstring->data) + 1));
+ name = strdup (ccstring->data);
if (!name) { err = KRB5_CC_NOMEM; }
}
if (!err) {
- strcpy (name, ccstring->data);
ccapi_data->cache_name = name;
name = NULL; /* take ownership */
if (!(ccapi_data = (stdccCacheDataPtr)malloc(sizeof(stdccCacheData))))
goto errout;
- if (!(cName = malloc(strlen(residual)+1)))
+ if (!(cName = strdup(residual)))
goto errout;
newCache->ops = &krb5_cc_stdcc_ops;
newCache->data = ccapi_data;
ccapi_data->cache_name = cName;
- strcpy(cName, residual);
-
err = cc_open(gCntrlBlock, cName, CC_CRED_V5, 0L,
&ccapi_data->NamedCache);
if (err != CC_NOERROR) {
return err;
}
- if ((data->name = (char *)calloc(strlen(name) + 1, sizeof(char))) == NULL) {
+ if ((data->name = strdup(name)) == NULL) {
k5_mutex_destroy(&data->lock);
krb5_xfree(data);
krb5_xfree(*id);
return(ENOMEM);
}
- (void) strcpy(data->name, name);
data->openf = 0;
data->version = 0;
data->iter_count = 0;
goto done;
}
- if ((data->name = (char *)calloc(strlen(name) + 1, sizeof(char))) == NULL) {
+ if ((data->name = strdup(name)) == NULL) {
k5_mutex_destroy(&data->lock);
krb5_xfree(data);
krb5_xfree(list->keytab);
goto done;
}
- (void) strcpy(data->name, name);
-
data->link = NULL;
data->refcount = 0;
list->keytab->data = (krb5_pointer)data;
return(ENOMEM);
}
- data->name = (char *)malloc(strlen(name) + 1);
+ data->name = strdup(name);
if (data->name == NULL) {
krb5_xfree(data);
krb5_xfree(*id);
return(ENOMEM);
}
- (void) strcpy(data->name, name);
data->openf = 0;
(*id)->data = (krb5_pointer)data;
if (!nameval[0]) {
retval = ENOENT;
} else {
- *ret_value = malloc(strlen(nameval[0]) + 1);
+ *ret_value = strdup(nameval[0]);
if (!*ret_value)
retval = ENOMEM;
- else
- strcpy(*ret_value, nameval[0]);
}
profile_free_list(nameval);
return -EINVAL;
length = strlen(realm);
- newrealm = malloc(length+1); /* Include room for the null */
+ newrealm = strdup(realm);
if (!newrealm)
return -ENOMEM;
- strcpy(newrealm, realm);
(void) krb5_xfree(krb5_princ_realm(context,principal)->data);
if (name != NULL) {
if (!err) {
/* If the name isn't NULL, make a copy of it */
- new_ccname = malloc (strlen (name) + 1);
+ new_ccname = strdup (name);
if (new_ccname == NULL) { err = ENOMEM; }
}
-
- if (!err) {
- strcpy (new_ccname, name);
- }
}
if (!err) {
krb5_get_default_realm(krb5_context context, char **lrealm)
{
char *realm = 0;
- char *cp;
krb5_error_code retval;
if (!context || (context->magic != KV5M_CONTEXT))
&realm);
if (!retval && realm) {
- context->default_realm = malloc(strlen(realm) + 1);
+ context->default_realm = strdup(realm);
if (!context->default_realm) {
profile_release_string(realm);
return ENOMEM;
}
- strcpy(context->default_realm, realm);
profile_release_string(realm);
}
}
realm = context->default_realm;
- if (!(*lrealm = cp = malloc((unsigned int) strlen(realm) + 1)))
+ if (!(*lrealm = strdup(realm)))
return ENOMEM;
- strcpy(cp, realm);
return(0);
}
NULL */
if (!lrealm) return 0;
- context->default_realm = malloc(strlen (lrealm) + 1);
+ context->default_realm = strdup(lrealm);
if (!context->default_realm)
return ENOMEM;
- strcpy(context->default_realm, lrealm);
return(0);
}
#ifdef DEBUG_REFERRALS
printf(" temp_realm is %s\n",temp_realm);
#endif
- realm = malloc(strlen(temp_realm) + 1);
+ realm = strdup(temp_realm);
if (!realm) {
profile_release_string(temp_realm);
return ENOMEM;
}
- strcpy(realm, temp_realm);
profile_release_string(temp_realm);
}
if (realm == (char *)NULL) {
- if (!(cp = (char *)malloc(strlen(KRB5_REFERRAL_REALM)+1)))
+ if (!(cp = strdup(KRB5_REFERRAL_REALM)))
return ENOMEM;
- strcpy(cp, KRB5_REFERRAL_REALM);
realm = cp;
}
if (realm == (char *)NULL) {
if (default_realm != (char *)NULL) {
/* We are defaulting to the realm of the host */
- if (!(cp = (char *)malloc(strlen(default_realm)+1)))
+ if (!(cp = strdup(default_realm)))
return ENOMEM;
- strcpy(cp, default_realm);
realm = cp;
/* Assume the realm name is upper case */
char *env = getenv("KRB5_CONFIG");
if (env)
{
- name = malloc(strlen(env) + 1);
+ name = strdup(env);
if (!name) return ENOMEM;
- strcpy(name, env);
}
}
if (!name && !secure)
} while (ch != EOF && ch != '\n');
read_string[sizeof(read_string)-1] = 0;
- if ((p->response = malloc(strlen(read_string)+1)) == NULL) {
+ if ((p->response = strdup(read_string)) == NULL) {
errno = ENOMEM;
goto cleanup;
}
- strcpy(p->response, read_string);
if ((p->flags & KRB5_UIO_ECHORESPONSE) == 0) {
(void) putchar('\n');
"default_domain", realm, &temp_domain);
if (!retval && temp_domain)
{
- *domain = malloc(strlen(temp_domain) + 1);
+ *domain = strdup(temp_domain);
if (!*domain) {
retval = ENOMEM;
- } else {
- strcpy(*domain, temp_domain);
}
profile_release_string(temp_domain);
}
return KRB5_RC_MALLOC;
id->data = (krb5_pointer) t;
if (name) {
- t->name = malloc(strlen(name)+1);
+ t->name = strdup(name);
if (!t->name) {
retval = KRB5_RC_MALLOC;
goto cleanup;
}
- strcpy(t->name, name);
} else
t->name = 0;
t->numhits = t->nummisses = 0;
GETDIR;
if (full_pathname) {
- if (!(d->fn = malloc(strlen(full_pathname) + 1)))
+ if (!(d->fn = strdup(full_pathname)))
return KRB5_RC_IO_MALLOC;
- (void) strcpy(d->fn, full_pathname);
} else {
if (!(d->fn = malloc(strlen(fn) + dirlen + 1)))
return KRB5_RC_IO_MALLOC;
if (values[0] == NULL) {
retval = ENOENT;
} else {
- *ret_value = malloc(strlen(values[0]) + 1);
+ *ret_value = strdup(values[0]);
if (*ret_value == NULL)
retval = ENOMEM;
- else
- strcpy(*ret_value, values[0]);
}
profile_free_list(values);
if (values[0] == NULL) {
retval = ENOENT;
} else {
- *ret_value = malloc(strlen(values[0]) + 1);
+ *ret_value = strdup(values[0]);
if (*ret_value == NULL)
retval = ENOMEM;
- else
- strcpy(*ret_value, values[0]);
}
profile_free_list(values);
else
text = error_message(err_code);
error.text.length = strlen(text) + 1;
- error.text.data = malloc((unsigned int) error.text.length);
+ error.text.data = strdup(text);
if (error.text.data) {
- strcpy(error.text.data, text);
if (!krb5_mk_error(context, &error, &outbuf)) {
(void) krb5_write_message(context, (void *)&fd,&outbuf);
krb5_free_data_contents(context, &outbuf);
}
}
error.text.length = strlen(text) + 1;
- error.text.data = malloc(error.text.length);
+ error.text.data = strdup(text);
if (error.text.data) {
- strcpy(error.text.data, text);
if (!krb5_mk_error(context, &error, &outbuf)) {
(void) krb5_write_message(context, (void *)&fd,&outbuf);
krb5_free_data_contents(context, &outbuf);
info[i]->etype = i;
sprintf(buf, "Morton's #%d", i);
info[i]->length = strlen(buf);
- info[i]->salt = malloc((size_t) (info[i]->length+1));
+ info[i]->salt = (unsigned char *) strdup(buf);
if (info[i]->salt == 0)
goto memfail;
- strcpy((char *) info[i]->salt, buf);
info[i]->s2kparams.data = NULL;
info[i]->s2kparams.length = 0;
info[i]->magic = KV5M_ETYPE_INFO_ENTRY;
info[i]->etype = i;
sprintf(buf, "Morton's #%d", i);
info[i]->length = strlen(buf);
- info[i]->salt = malloc((size_t) (info[i]->length+1));
+ info[i]->salt = (unsigned char *) strdup(buf);
if (info[i]->salt == 0)
goto memfail;
- strcpy((char *) info[i]->salt, buf);
sprintf(buf, "s2k: %d", i);
info[i]->s2kparams.data = malloc(strlen(buf)+1);
if (info[i]->s2kparams.data == NULL)
if (*s != NULL) free(*s);
if (code==NULL) {
- *s = (char*)calloc(strlen("<NULL>")+1, sizeof(char));
+ *s = strdup("<NULL>");
if (*s == NULL) return ENOMEM;
- strcpy(*s,"<NULL>");
} else if (code->data == NULL || ((int) code->length) <= 0) {
- *s = (char*)calloc(strlen("<EMPTY>")+1, sizeof(char));
+ *s = strdup("<EMPTY>");
if (*s==NULL) return ENOMEM;
- strcpy(*s,"<EMPTY>");
} else {
unsigned int i;
ds(string)
char const *string;
{
- char *rv;
- rv = malloc(strlen(string)+1);
- strcpy(rv, string);
- return(rv);
+ return strdup(string);
}
char *
list->max = newmax;
list->list = newlist;
}
- newstr = malloc(strlen(str)+1);
+ newstr = strdup(str);
if (newstr == 0)
return ENOMEM;
- strcpy(newstr, str);
list->list[list->num++] = newstr;
list->list[list->num] = 0;
value = def_val;
if (value) {
- *ret_string = malloc(strlen(value)+1);
+ *ret_string = strdup(value);
if (*ret_string == 0)
return ENOMEM;
- strcpy(*ret_string, value);
} else
*ret_string = 0;
return 0;
if (!node->value)
return PROF_SET_SECTION_VALUE;
- cp = malloc(strlen(new_value)+1);
+ cp = strdup(new_value);
if (!cp)
return ENOMEM;
- strcpy(cp, new_value);
free(node->value);
node->value = cp;
/*
* Make sure we can allocate memory for the new name, first!
*/
- new_string = malloc(strlen(new_name)+1);
+ new_string = strdup(new_name);
if (!new_string)
return ENOMEM;
- strcpy(new_string, new_name);
/*
* Find the place to where the new node should go. We look
}
info->info_dirs = dirs;
dirs[n_dirs + 1] = (char *)NULL;
- dirs[n_dirs] = malloc((unsigned)strlen(info_dir)+1);
- strcpy(dirs[n_dirs], info_dir);
+ dirs[n_dirs] = strdup(info_dir);
*code_ptr = 0;
}
if (islower(*cp))
*cp = toupper(*cp);
}
- cp = malloc(strlen(tmp)+1);
+ cp = strdup(tmp);
if (!cp) {
fprintf(stderr,
"wconfig: malloc failed!\n");
exit(1);
}
- strcpy(cp, tmp);
add_ignore_list(cp);
argc--; argv++;
continue;