summaryrefslogtreecommitdiffstats
path: root/src/lib/rpc
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2000-06-27 21:00:02 +0000
committerKen Raeburn <raeburn@mit.edu>2000-06-27 21:00:02 +0000
commit9fe2a01ec0fefa8b764bb6e9d7f9a09d11fed7ff (patch)
tree2d4fd8b1bf6272f1286ffb7af9ae1d351a347e71 /src/lib/rpc
parent0d54ee19a3e5a159f0b86097ebfe193a0d9c26d8 (diff)
downloadkrb5-9fe2a01ec0fefa8b764bb6e9d7f9a09d11fed7ff.tar.gz
krb5-9fe2a01ec0fefa8b764bb6e9d7f9a09d11fed7ff.tar.xz
krb5-9fe2a01ec0fefa8b764bb6e9d7f9a09d11fed7ff.zip
pullup from 1.2 branch
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12442 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/rpc')
-rw-r--r--src/lib/rpc/ChangeLog33
-rw-r--r--src/lib/rpc/auth_gssapi_misc.c16
-rw-r--r--src/lib/rpc/clnt_perror.c84
-rw-r--r--src/lib/rpc/clnt_simple.c5
-rw-r--r--src/lib/rpc/clnt_tcp.c2
-rw-r--r--src/lib/rpc/clnt_udp.c2
-rw-r--r--src/lib/rpc/get_myaddress.c2
-rw-r--r--src/lib/rpc/pmap_rmt.c11
-rw-r--r--src/lib/rpc/svc_auth_gssapi.c14
-rw-r--r--src/lib/rpc/unit-test/ChangeLog6
-rw-r--r--src/lib/rpc/unit-test/lib/helpers.exp6
11 files changed, 124 insertions, 57 deletions
diff --git a/src/lib/rpc/ChangeLog b/src/lib/rpc/ChangeLog
index 392e7d9fa..7d0aa318a 100644
--- a/src/lib/rpc/ChangeLog
+++ b/src/lib/rpc/ChangeLog
@@ -1,3 +1,36 @@
+2000-05-31 Ken Raeburn <raeburn@mit.edu>
+
+ * pmap_rmt.c (GIFCONF_BUFSIZE): New macro.
+ (getbroadcastnets): Use it for buffer size.
+ (clnt_broadcast): Make buffer at least that big.
+
+ * get_myaddress.c (get_myaddress): Increase buffer size.
+
+2000-05-18 Ken Raeburn <raeburn@mit.edu>
+
+ * auth_gssapi_misc.c (auth_gssapi_display_status_1): Don't pass a
+ gss_buffer_desc to fprintf.
+
+ * clnt_tcp.c (clnttcp_create): Initialize "ct".
+ * clnt_udp.c (clntudp_bufcreate): Initialize "cu".
+
+ * svc_auth_gssapi.c (_svcauth_gssapi, create_client,
+ destroy_client, dump_db, clean_client): Use %p format for
+ displaying pointers. Remove unused variables.
+
+2000-05-17 Ken Raeburn <raeburn@mit.edu>
+ Nalin Dahyabhai <nalin@redhat.com>
+
+ * clnt_perror.c (clnt_sperror): Don't overflow buffer "str" beyond
+ known allocation size.
+ * clnt_simple.c (gssrpc_callrpc): Don't overfill buffer "crp->oldhost".
+
+2000-05-03 Nalin Dahyabhai <nalin@redhat.com>
+
+ * clnt_perror.c (_buf): Use bigger buffer.
+ (clnt_spcreateerror): Don't overflow buffer "buf" beyond known
+ allocation size.
+
2000-02-22 Donn Cave <donn@u.washington.edu>
* Makefile.in (includes): Extract basename of header file to be
diff --git a/src/lib/rpc/auth_gssapi_misc.c b/src/lib/rpc/auth_gssapi_misc.c
index fd9393c32..e7c38a820 100644
--- a/src/lib/rpc/auth_gssapi_misc.c
+++ b/src/lib/rpc/auth_gssapi_misc.c
@@ -162,15 +162,17 @@ static void auth_gssapi_display_status_1(m, code, type, rec)
auth_gssapi_display_status_1(m,gssstat,GSS_C_GSS_CODE,1);
auth_gssapi_display_status_1(m, minor_stat,
GSS_C_MECH_CODE, 1);
- } else
- fprintf(stderr,
- "GSS-API authentication error %s: recursive failure!\n",
- msg);
+ } else {
+ fputs ("GSS-API authentication error ", stderr);
+ fwrite (msg.value, msg.length, 1, stderr);
+ fputs (": recursive failure!\n", stderr);
+ }
return;
}
-
- fprintf(stderr, "GSS-API authentication error %s: %s\n", m,
- (char *)msg.value);
+
+ fprintf (stderr, "GSS-API authentication error %s: ", m);
+ fwrite (msg.value, msg.length, 1, stderr);
+ putc ('\n', stderr);
(void) gss_release_buffer(&minor_stat, &msg);
if (!msg_ctx)
diff --git a/src/lib/rpc/clnt_perror.c b/src/lib/rpc/clnt_perror.c
index 560cb27b7..06dd22e96 100644
--- a/src/lib/rpc/clnt_perror.c
+++ b/src/lib/rpc/clnt_perror.c
@@ -57,9 +57,8 @@ static char *buf;
static char *
_buf()
{
-
- if (buf == 0)
- buf = (char *)malloc(256);
+ if (buf == NULL)
+ buf = (char *)malloc(BUFSIZ);
return (buf);
}
@@ -74,17 +73,20 @@ clnt_sperror(rpch, s)
struct rpc_err e;
void clnt_perrno();
char *err;
- char *str = _buf();
+ char *bufstart = _buf();
+ char *str = bufstart;
char *strstart = str;
if (str == 0)
return (0);
CLNT_GETERR(rpch, &e);
- (void) sprintf(str, "%s: ", s);
+ strncpy (str, s, BUFSIZ - 1);
+ str[BUFSIZ - 1] = 0;
+ strncat (str, ": ", BUFSIZ - 1 - strlen (bufstart));
str += strlen(str);
-
- (void) strcpy(str, clnt_sperrno(e.re_status));
+ strncat (str, clnt_sperrno(e.re_status), BUFSIZ - 1 - strlen (bufstart));
+ str[BUFSIZ - 1] = '\0';
str += strlen(str);
switch (e.re_status) {
@@ -105,47 +107,64 @@ clnt_sperror(rpch, s)
case RPC_CANTSEND:
case RPC_CANTRECV:
- (void) sprintf(str, "; errno = %s",
- sys_errlist[e.re_errno]);
+ /* 10 for the string */
+ if(str - bufstart + 10 + strlen(sys_errlist[e.re_errno]) < BUFSIZ)
+ (void) sprintf(str, "; errno = %s",
+ sys_errlist[e.re_errno]);
str += strlen(str);
break;
case RPC_VERSMISMATCH:
- (void) sprintf(str,
- "; low version = %lu, high version = %lu",
- e.re_vers.low, e.re_vers.high);
+ /* 33 for the string, 22 for the numbers */
+ if(str - bufstart + 33 + 22 < BUFSIZ)
+ (void) sprintf(str,
+ "; low version = %lu, high version = %lu",
+ (unsigned long) e.re_vers.low,
+ (unsigned long) e.re_vers.high);
str += strlen(str);
break;
case RPC_AUTHERROR:
err = auth_errmsg(e.re_why);
- (void) sprintf(str,"; why = ");
+ /* 8 for the string */
+ if(str - bufstart + 8 < BUFSIZ)
+ (void) sprintf(str,"; why = ");
str += strlen(str);
if (err != NULL) {
- (void) sprintf(str, "%s",err);
+ if(str - bufstart + strlen(err) < BUFSIZ)
+ (void) sprintf(str, "%s",err);
} else {
+ /* 33 for the string, 11 for the number */
+ if(str - bufstart + 33 + 11 < BUFSIZ)
(void) sprintf(str,
- "(unknown authentication error - %d)",
- (int) e.re_why);
+ "(unknown authentication error - %d)",
+ (int) e.re_why);
}
str += strlen(str);
break;
case RPC_PROGVERSMISMATCH:
- (void) sprintf(str,
- "; low version = %lu, high version = %lu",
- e.re_vers.low, e.re_vers.high);
+ /* 33 for the string, 22 for the numbers */
+ if(str - bufstart + 33 + 22 < BUFSIZ)
+ (void) sprintf(str,
+ "; low version = %lu, high version = %lu",
+ (unsigned long) e.re_vers.low,
+ (unsigned long) e.re_vers.high);
str += strlen(str);
break;
default: /* unknown */
- (void) sprintf(str,
- "; s1 = %lu, s2 = %lu",
- e.re_lb.s1, e.re_lb.s2);
+ /* 14 for the string, 22 for the numbers */
+ if(str - bufstart + 14 + 22 < BUFSIZ)
+ (void) sprintf(str,
+ "; s1 = %lu, s2 = %lu",
+ (unsigned long) e.re_lb.s1,
+ (unsigned long) e.re_lb.s2);
str += strlen(str);
break;
}
- (void) sprintf(str, "\n");
+ if(str - bufstart + 1 < BUFSIZ)
+ (void) sprintf(str, "\n");
return(strstart) ;
}
@@ -238,26 +257,29 @@ clnt_spcreateerror(s)
if (str == 0)
return(0);
(void) sprintf(str, "%s: ", s);
- (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat));
+ str[BUFSIZ - 1] = '\0';
+ (void) strncat(str, clnt_sperrno(rpc_createerr.cf_stat), BUFSIZ - 1);
switch (rpc_createerr.cf_stat) {
case RPC_PMAPFAILURE:
- (void) strcat(str, " - ");
- (void) strcat(str,
- clnt_sperrno(rpc_createerr.cf_error.re_status));
+ (void) strncat(str, " - ", BUFSIZ - 1 - strlen(str));
+ (void) strncat(str,
+ clnt_sperrno(rpc_createerr.cf_error.re_status),
+ BUFSIZ - 1 - strlen(str));
break;
case RPC_SYSTEMERROR:
- (void) strcat(str, " - ");
+ (void) strncat(str, " - ", BUFSIZ - 1 - strlen(str));
if (rpc_createerr.cf_error.re_errno > 0
&& rpc_createerr.cf_error.re_errno < sys_nerr)
- (void) strcat(str,
- sys_errlist[rpc_createerr.cf_error.re_errno]);
+ (void) strncat(str,
+ sys_errlist[rpc_createerr.cf_error.re_errno],
+ BUFSIZ - 1 - strlen(str));
else
(void) sprintf(&str[strlen(str)], "Error %d",
rpc_createerr.cf_error.re_errno);
break;
}
- (void) strcat(str, "\n");
+ (void) strncat(str, "\n", BUFSIZ - 1 - strlen(str));
return (str);
}
diff --git a/src/lib/rpc/clnt_simple.c b/src/lib/rpc/clnt_simple.c
index b3d2eb330..2f203d73f 100644
--- a/src/lib/rpc/clnt_simple.c
+++ b/src/lib/rpc/clnt_simple.c
@@ -70,6 +70,8 @@ gssrpc_callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
}
if (crp->oldhost == NULL) {
crp->oldhost = mem_alloc(256);
+ if (crp->oldhost == 0)
+ return 0;
crp->oldhost[0] = 0;
crp->socket = RPC_ANYSOCK;
}
@@ -98,7 +100,8 @@ gssrpc_callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
crp->valid = 1;
crp->oldprognum = prognum;
crp->oldversnum = versnum;
- (void) strcpy(crp->oldhost, host);
+ (void) strncpy(crp->oldhost, host, 255);
+ crp->oldhost[255] = '\0';
}
tottimeout.tv_sec = 25;
tottimeout.tv_usec = 0;
diff --git a/src/lib/rpc/clnt_tcp.c b/src/lib/rpc/clnt_tcp.c
index 4e10a489f..f87da78b1 100644
--- a/src/lib/rpc/clnt_tcp.c
+++ b/src/lib/rpc/clnt_tcp.c
@@ -116,7 +116,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
unsigned int recvsz;
{
CLIENT *h;
- register struct ct_data *ct;
+ register struct ct_data *ct = 0;
struct timeval now;
struct rpc_msg call_msg;
diff --git a/src/lib/rpc/clnt_udp.c b/src/lib/rpc/clnt_udp.c
index 60469429d..df3945a48 100644
--- a/src/lib/rpc/clnt_udp.c
+++ b/src/lib/rpc/clnt_udp.c
@@ -117,7 +117,7 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
unsigned int recvsz;
{
CLIENT *cl;
- register struct cu_data *cu;
+ register struct cu_data *cu = 0;
struct timeval now;
struct rpc_msg call_msg;
diff --git a/src/lib/rpc/get_myaddress.c b/src/lib/rpc/get_myaddress.c
index 4c9bf29ac..13bafa009 100644
--- a/src/lib/rpc/get_myaddress.c
+++ b/src/lib/rpc/get_myaddress.c
@@ -81,7 +81,7 @@ get_myaddress(addr)
struct sockaddr_in *addr;
{
int s;
- char buf[BUFSIZ];
+ char buf[256 * sizeof (struct ifconf)];
struct ifconf ifc;
struct ifreq ifreq, *ifr;
int len;
diff --git a/src/lib/rpc/pmap_rmt.c b/src/lib/rpc/pmap_rmt.c
index 7cafe6e01..dc9735d84 100644
--- a/src/lib/rpc/pmap_rmt.c
+++ b/src/lib/rpc/pmap_rmt.c
@@ -165,6 +165,8 @@ xdr_rmtcallres(xdrs, crp)
* routines which only support udp/ip .
*/
+#define GIFCONF_BUFSIZE (256 * sizeof (struct ifconf))
+
static int
getbroadcastnets(addrs, sock, buf)
struct in_addr *addrs;
@@ -176,8 +178,9 @@ getbroadcastnets(addrs, sock, buf)
struct sockaddr_in *sin;
int n, i;
- ifc.ifc_len = UDPMSGSIZE;
+ ifc.ifc_len = GIFCONF_BUFSIZE;
ifc.ifc_buf = buf;
+ memset (buf, 0, GIFCONF_BUFSIZE);
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
perror("broadcast: ioctl (get interface configuration)");
return (0);
@@ -255,7 +258,11 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
struct rmtcallres r;
struct rpc_msg msg;
struct timeval t;
- char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE];
+ char outbuf[MAX_BROADCAST_SIZE];
+#ifndef MAX
+#define MAX(A,B) ((A)<(B)?(B):(A))
+#endif
+ char inbuf[MAX (UDPMSGSIZE, GIFCONF_BUFSIZE)];
/*
* initialization: create a socket, a broadcast address, and
diff --git a/src/lib/rpc/svc_auth_gssapi.c b/src/lib/rpc/svc_auth_gssapi.c
index 827596a3b..34ee0ef11 100644
--- a/src/lib/rpc/svc_auth_gssapi.c
+++ b/src/lib/rpc/svc_auth_gssapi.c
@@ -134,7 +134,6 @@ enum auth_stat _svcauth_gssapi(rqst, msg, no_dispatch)
svc_auth_gssapi_data *client_data;
int ret_flags, ret, i;
rpc_u_int32 seq_num;
- int flag;
PRINTF(("svcauth_gssapi: starting\n"));
@@ -307,8 +306,6 @@ enum auth_stat _svcauth_gssapi(rqst, msg, no_dispatch)
#endif
if (call_arg.version >= 3) {
- int len;
-
memset(&bindings, 0, sizeof(bindings));
bindings.application_data.length = 0;
bindings.initiator_addrtype = GSS_C_AF_INET;
@@ -657,7 +654,6 @@ static svc_auth_gssapi_data *create_client()
client_list *c;
svc_auth_gssapi_data *client_data;
static int client_key = 1;
- int ret;
PRINTF(("svcauth_gssapi: empty creds, creating\n"));
@@ -665,7 +661,7 @@ static svc_auth_gssapi_data *create_client()
if (client_data == NULL)
return NULL;
memset((char *) client_data, 0, sizeof(*client_data));
- L_PRINTF(2, ("create_client: new client_data = %#x\n", client_data));
+ L_PRINTF(2, ("create_client: new client_data = %p\n", client_data));
/* set up client data structure */
client_data->established = 0;
@@ -783,10 +779,9 @@ static void destroy_client(client_data)
OM_uint32 gssstat, minor_stat;
gss_buffer_desc out_buf;
client_list *c, *c2;
- int ret;
PRINTF(("destroy_client: destroying client_data\n"));
- L_PRINTF(2, ("destroy_client: client_data = %#x\n", client_data));
+ L_PRINTF(2, ("destroy_client: client_data = %p\n", client_data));
#ifdef DEBUG_GSSAPI
if (svc_debug_gssapi >= 3)
@@ -852,7 +847,7 @@ static void dump_db(msg)
c = clients;
while (c) {
client_data = c->client;
- L_PRINTF(3, ("\tclient_data = %#x, exp = %d\n",
+ L_PRINTF(3, ("\tclient_data = %p, exp = %d\n",
client_data, client_data->expiration));
c = c->next;
}
@@ -871,7 +866,7 @@ static void clean_client()
while (c) {
client_data = c->client;
- L_PRINTF(2, ("clean_client: client_data = %#x\n",
+ L_PRINTF(2, ("clean_client: client_data = %p\n",
client_data));
if (client_data->expiration < time(0)) {
@@ -884,7 +879,6 @@ static void clean_client()
}
}
-done:
PRINTF(("clean_client: done\n"));
}
diff --git a/src/lib/rpc/unit-test/ChangeLog b/src/lib/rpc/unit-test/ChangeLog
index aa14bfc87..0a21776c3 100644
--- a/src/lib/rpc/unit-test/ChangeLog
+++ b/src/lib/rpc/unit-test/ChangeLog
@@ -1,3 +1,9 @@
+2000-06-08 Tom Yu <tlyu@mit.edu>
+
+ * lib/helpers.exp (kinit): Move "expect eof" into the commands
+ that send the prompt. Don't "expect eof" outside of the main
+ expect, as the main expect may have already read eof.
+
2000-02-15 Tom Yu <tlyu@mit.edu>
* server.c: Add code to set a signal handler for SIGHUP and a few
diff --git a/src/lib/rpc/unit-test/lib/helpers.exp b/src/lib/rpc/unit-test/lib/helpers.exp
index 3d7b167fc..c4b76aa0c 100644
--- a/src/lib/rpc/unit-test/lib/helpers.exp
+++ b/src/lib/rpc/unit-test/lib/helpers.exp
@@ -23,10 +23,10 @@ proc kinit {princ pass lifetime} {
spawn -noecho $kinit -5 -l $lifetime $princ
expect {
- -re "Password for $princ.*: " { send "$pass\n" }
+ -re "Password for $princ.*: " { send "$pass\n"; expect eof }
timeout { perror "Timeout waiting for kinit"; close }
+ eof
}
- expect { eof {} }
set ret [wait]
if {[lindex $ret $wait_error_index] == -1} {
@@ -117,7 +117,7 @@ proc wait_client {testname ccname id status} {
set env(KRB5CCNAME) FILE:/tmp/krb5cc_rpc_test_$ccname
if {[catch "exec $kdestroy -5"] != 0} {
- error "$testname: cannot destroy client $ccname ccache"
+ perror "$testname: cannot destroy client $ccname ccache"
}
unset env(KRB5CCNAME)