use strlcat/strlcpy, from openbsd
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12046 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -166,28 +166,32 @@ expand_realms(krb5_context context,
|
|||||||
for(r = realms; r; r = r->next){
|
for(r = realms; r; r = r->next){
|
||||||
if(r->trailing_dot){
|
if(r->trailing_dot){
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
size_t len = strlen(r->realm) + strlen(prev_realm) + 1;
|
||||||
|
|
||||||
if(prev_realm == NULL)
|
if(prev_realm == NULL)
|
||||||
prev_realm = client_realm;
|
prev_realm = client_realm;
|
||||||
tmp = realloc(r->realm, strlen(r->realm) + strlen(prev_realm) + 1);
|
tmp = realloc(r->realm, len);
|
||||||
if(tmp == NULL){
|
if(tmp == NULL){
|
||||||
free_realms(realms);
|
free_realms(realms);
|
||||||
krb5_set_error_string (context, "malloc: out of memory");
|
krb5_set_error_string (context, "malloc: out of memory");
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
r->realm = tmp;
|
r->realm = tmp;
|
||||||
strcat(r->realm, prev_realm);
|
strlcat(r->realm, prev_realm, len);
|
||||||
}else if(r->leading_slash && !r->leading_space && prev_realm){
|
}else if(r->leading_slash && !r->leading_space && prev_realm){
|
||||||
/* yet another exception: if you use x500-names, the
|
/* yet another exception: if you use x500-names, the
|
||||||
leading realm doesn't have to be "quoted" with a space */
|
leading realm doesn't have to be "quoted" with a space */
|
||||||
char *tmp;
|
char *tmp;
|
||||||
tmp = malloc(strlen(r->realm) + strlen(prev_realm) + 1);
|
size_t len = strlen(r->realm) + strlen(prev_realm) + 1;
|
||||||
|
|
||||||
|
tmp = malloc(len);
|
||||||
if(tmp == NULL){
|
if(tmp == NULL){
|
||||||
free_realms(realms);
|
free_realms(realms);
|
||||||
krb5_set_error_string (context, "malloc: out of memory");
|
krb5_set_error_string (context, "malloc: out of memory");
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
strcpy(tmp, prev_realm);
|
strlcpy(tmp, prev_realm, len);
|
||||||
strcat(tmp, r->realm);
|
strlcat(tmp, r->realm, len);
|
||||||
free(r->realm);
|
free(r->realm);
|
||||||
r->realm = tmp;
|
r->realm = tmp;
|
||||||
}
|
}
|
||||||
@@ -368,10 +372,10 @@ krb5_domain_x500_encode(char **realms, int num_realms, krb5_data *encoding)
|
|||||||
*s = '\0';
|
*s = '\0';
|
||||||
for(i = 0; i < num_realms; i++){
|
for(i = 0; i < num_realms; i++){
|
||||||
if(i && i < num_realms - 1)
|
if(i && i < num_realms - 1)
|
||||||
strcat(s, ",");
|
strlcat(s, ",", len + 1);
|
||||||
if(realms[i][0] == '/')
|
if(realms[i][0] == '/')
|
||||||
strcat(s, " ");
|
strlcat(s, " ", len + 1);
|
||||||
strcat(s, realms[i]);
|
strlcat(s, realms[i], len + 1);
|
||||||
}
|
}
|
||||||
encoding->data = s;
|
encoding->data = s;
|
||||||
encoding->length = strlen(s);
|
encoding->length = strlen(s);
|
||||||
|
@@ -52,9 +52,9 @@ _warnerr(krb5_context context, int do_errtext,
|
|||||||
args[0] = args[1] = NULL;
|
args[0] = args[1] = NULL;
|
||||||
arg = args;
|
arg = args;
|
||||||
if(fmt){
|
if(fmt){
|
||||||
strcat(xfmt, "%s");
|
strlcat(xfmt, "%s", sizeof(xfmt));
|
||||||
if(do_errtext)
|
if(do_errtext)
|
||||||
strcat(xfmt, ": ");
|
strlcat(xfmt, ": ", sizeof(xfmt));
|
||||||
vasprintf(&msg, fmt, ap);
|
vasprintf(&msg, fmt, ap);
|
||||||
if(msg == NULL)
|
if(msg == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
@@ -63,7 +63,7 @@ _warnerr(krb5_context context, int do_errtext,
|
|||||||
if(context && do_errtext){
|
if(context && do_errtext){
|
||||||
const char *err_msg;
|
const char *err_msg;
|
||||||
|
|
||||||
strcat(xfmt, "%s");
|
strlcat(xfmt, "%s", sizeof(xfmt));
|
||||||
|
|
||||||
err_str = krb5_get_error_string(context);
|
err_str = krb5_get_error_string(context);
|
||||||
if (err_str != NULL) {
|
if (err_str != NULL) {
|
||||||
|
Reference in New Issue
Block a user