summaryrefslogtreecommitdiffstats
path: root/src/slave
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2008-12-01 17:09:59 +0000
committerGreg Hudson <ghudson@mit.edu>2008-12-01 17:09:59 +0000
commit0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b (patch)
tree3ab0a7b22c93fd929b1f532e98618d62f1a848d9 /src/slave
parent689e929e5e0240684408bb0bc53d536f5696cdea (diff)
Convert many uses of sprintf to snprintf or asprintf
ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21258 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/slave')
-rw-r--r--src/slave/kprop.c12
-rw-r--r--src/slave/kpropd.c18
2 files changed, 14 insertions, 16 deletions
diff --git a/src/slave/kprop.c b/src/slave/kprop.c
index a2542363e..5f68f29e8 100644
--- a/src/slave/kprop.c
+++ b/src/slave/kprop.c
@@ -241,7 +241,7 @@ void get_tickets(context)
* Initialize cache file which we're going to be using
*/
(void) mktemp(tkstring);
- sprintf(buf, "FILE:%s", tkstring);
+ snprintf(buf, sizeof(buf), "FILE:%s", tkstring);
retval = krb5_cc_resolve(context, buf, &ccache);
if (retval) {
@@ -337,7 +337,7 @@ open_connection(host, fd, Errmsg, ErrmsgSz)
hp = gethostbyname(host);
if (hp == NULL) {
- (void) sprintf(Errmsg, "%s: unknown host", host);
+ (void) snprintf(Errmsg, ErrmsgSz, "%s: unknown host", host);
*fd = -1;
return(0);
}
@@ -355,13 +355,13 @@ open_connection(host, fd, Errmsg, ErrmsgSz)
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0) {
- (void) sprintf(Errmsg, "in call to socket");
+ (void) snprintf(Errmsg, ErrmsgSz, "in call to socket");
return(errno);
}
if (connect(s, (struct sockaddr *)&my_sin, sizeof my_sin) < 0) {
retval = errno;
close(s);
- (void) sprintf(Errmsg, "in call to connect");
+ (void) snprintf(Errmsg, ErrmsgSz, "in call to connect");
return(retval);
}
*fd = s;
@@ -379,7 +379,7 @@ open_connection(host, fd, Errmsg, ErrmsgSz)
if (getsockname(s, (struct sockaddr *)&my_sin, &socket_length) < 0) {
retval = errno;
close(s);
- (void) sprintf(Errmsg, "in call to getsockname");
+ (void) snprintf(Errmsg, ErrmsgSz, "in call to getsockname");
return(retval);
}
sender_addr.addrtype = ADDRTYPE_INET;
@@ -597,7 +597,7 @@ xmit_database(context, auth_context, my_creds, fd, database_fd,
retval = krb5_mk_priv(context, auth_context, &inbuf,
&outbuf, NULL);
if (retval) {
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"while encoding database block starting at %d",
sent_size);
com_err(progname, retval, buf);
diff --git a/src/slave/kpropd.c b/src/slave/kpropd.c
index bee5db0b1..2de921255 100644
--- a/src/slave/kpropd.c
+++ b/src/slave/kpropd.c
@@ -1432,7 +1432,7 @@ recv_database(context, fd, database_fd, confmsg)
while (received_size < database_size) {
retval = krb5_read_message(context, (void *) &fd, &inbuf);
if (retval) {
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"while reading database block starting at offset %d",
received_size);
com_err(progname, retval, buf);
@@ -1444,7 +1444,7 @@ recv_database(context, fd, database_fd, confmsg)
retval = krb5_rd_priv(context, auth_context, &inbuf,
&outbuf, NULL);
if (retval) {
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"while decoding database block starting at offset %d",
received_size);
com_err(progname, retval, buf);
@@ -1456,12 +1456,12 @@ recv_database(context, fd, database_fd, confmsg)
krb5_free_data_contents(context, &inbuf);
krb5_free_data_contents(context, &outbuf);
if (n < 0) {
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"while writing database block starting at offset %d",
received_size);
send_error(context, fd, errno, buf);
} else if (n != outbuf.length) {
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"incomplete write while writing database block starting at \noffset %d (%d written, %d expected)",
received_size, n, outbuf.length);
send_error(context, fd, KRB5KRB_ERR_GENERIC, buf);
@@ -1472,7 +1472,7 @@ recv_database(context, fd, database_fd, confmsg)
* OK, we've seen the entire file. Did we get too many bytes?
*/
if (received_size > database_size) {
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"Received %d bytes, expected %d bytes for database file",
received_size, database_size);
send_error(context, fd, KRB5KRB_ERR_GENERIC, buf);
@@ -1521,8 +1521,8 @@ send_error(context, fd, err_code, err_text)
if (error.error > 127) {
error.error = KRB_ERR_GENERIC;
if (err_text) {
- sprintf(buf, "%s %s", error_message(err_code),
- err_text);
+ snprintf(buf, sizeof(buf), "%s %s",
+ error_message(err_code), err_text);
text = buf;
}
}
@@ -1674,12 +1674,10 @@ kadm5_get_kiprop_host_srv_name(krb5_context context,
host = params.admin_server; /* XXX */
- name = malloc(strlen(KADM5_KIPROP_HOST_SERVICE) + strlen(host) + 2);
- if (name == NULL) {
+ if (asprintf(&name, "%s/%s", KADM5_KIPROP_HOST_SERVICE, host) < 0) {
free(host);
return (ENOMEM);
}
- sprintf(name, "%s/%s", KADM5_KIPROP_HOST_SERVICE, host);
*host_service_name = name;
return (KADM5_OK);