summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog35
-rw-r--r--src/acconfig.h2
-rw-r--r--src/aclocal.m446
-rw-r--r--src/kdc/ChangeLog36
-rw-r--r--src/kdc/kdc_util.c36
-rw-r--r--src/kdc/kerberos_v4.c49
-rw-r--r--src/kdc/network.c40
-rw-r--r--src/slave/ChangeLog6
-rw-r--r--src/slave/kprop.c15
-rw-r--r--src/wconfig.c7
10 files changed, 224 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d920206e7f..def0d74238 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,38 @@
+2000-06-23 Ken Raeburn <raeburn@mit.edu>
+
+ * aclocal.m4 (KRB5_LIB_PARAMS): Don't need to display "checking"
+ message for AC_CANONICAL_HOST, it does that itself.
+
+2000-06-23 Tom Yu <tlyu@mit.edu>
+
+ * aclocal.m4 (CC_LINK_STATIC): Fix to use old library search
+ order; otherwise if there are shared libraries with the same name
+ elsewhere in the search path, they'll take precedence over the
+ static ones in the tree.
+ (AC_KRB5_TCL_TRYOLD): Search by appending stuff to CPPFLAGS and
+ LDFLAGS to notice if there may be problems with stuff earlier
+ along in either variable overriding.
+
+2000-06-23 Nalin Dahyabhai <nalin@redhat.com>
+
+ * wconfig.c (main): Warn if copying command-line option string
+ will overflow internal buffer.
+
+2000-06-23 Ken Raeburn <raeburn@mit.edu>
+
+ * aclocal.m4 (KRB5_AC_ENABLE_DNS): Set RESOLV_LIB, and substitute
+ it into the Makefile.
+ (AC_LIBRARY_NET): Set RESOLV_LIB.
+
+ * aclocal.m4 (KRB5_AC_ENABLE_DNS): Check for dns, dns-for-kdc, and
+ dns-for-realm separately. Define KRB5_DNS_LOOKUP if either mode
+ is enabled. Define KRB5_DNS_LOOKUP_KDC and KRB5_DNS_LOOKUP_REALM
+ if the appropriate modes are enabled.
+ * acconfig.h (KRB5_DNS_LOOKUP_KDC, KRB5_DNS_LOOKUP_REALM): Undef.
+
+ * aclocal.m4 (KRB5_LIB_PARAMS): Check for alpha*-dec-osf* instead
+ of alpha-dec-osf*.
+
2000-05-05 Wilfredo Sanchez <tritan@mit.edu>
* config/pre.in: Set KRB5_INCDIR from @includedir@ so configure
diff --git a/src/acconfig.h b/src/acconfig.h
index e6f00c77d4..7ac14f02cd 100644
--- a/src/acconfig.h
+++ b/src/acconfig.h
@@ -32,6 +32,8 @@
/* Define if DNS support for finding realms and KDC locations should
be compiled in. */
#undef KRB5_DNS_LOOKUP
+#undef KRB5_DNS_LOOKUP_KDC
+#undef KRB5_DNS_LOOKUP_REALM
/* Define to `long' if <sys/types.h> doesn't define. */
#undef time_t
diff --git a/src/aclocal.m4 b/src/aclocal.m4
index 79c31b21c0..df4a6c0abb 100644
--- a/src/aclocal.m4
+++ b/src/aclocal.m4
@@ -783,8 +783,8 @@ if test "$with_tcl" != no ; then
AC_CHECK_LIB(ld, main, DL_LIB=-lld)
krb5_save_CPPFLAGS="$CPPFLAGS"
krb5_save_LDFLAGS="$LDFLAGS"
- CPPFLAGS="$TCL_INCLUDES $CPPFLAGS"
- LDFLAGS="$TCL_LIBPATH $LDFLAGS"
+ CPPFLAGS="$CPPFLAGS $TCL_INCLUDES"
+ LDFLAGS="$LDFLAGS $TCL_LIBPATH"
tcl_header=no
AC_CHECK_HEADER(tcl.h,AC_DEFINE(HAVE_TCL_H) tcl_header=yes)
if test $tcl_header=no; then
@@ -1092,11 +1092,9 @@ dnl
dnl Determine parameters related to libraries, e.g. various extensions.
AC_DEFUN(KRB5_LIB_PARAMS,
-[AC_MSG_CHECKING([host system type])
-AC_CACHE_VAL(krb5_cv_host,
+[AC_CACHE_VAL(krb5_cv_host,
[AC_CANONICAL_HOST
krb5_cv_host=$host])
-AC_MSG_RESULT($krb5_cv_host)
AC_REQUIRE([AC_PROG_CC])
#
# Set up some defaults.
@@ -1119,7 +1117,7 @@ CC_LINK_STATIC='$(CC) $(PROG_LIBPATH)'
# Set up architecture-specific variables.
case $krb5_cv_host in
-alpha-dec-osf*)
+alpha*-dec-osf*)
SHLIBVEXT='.so.$(LIBMAJOR).$(LIBMINOR)'
SHLIBSEXT='.so.$(LIBMAJOR)'
SHLIBEXT=.so
@@ -1129,7 +1127,11 @@ alpha-dec-osf*)
SHLIB_EXPFLAGS='-rpath $(SHLIB_RDIRS) $(SHLIB_DIRS) $(SHLIB_EXPLIBS)'
PROFFLAGS=-pg
CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) -Wl,-rpath -Wl,$(PROG_RPATH)'
- CC_LINK_STATIC='$(CC) $(PROG_LIBPATH)'
+ # Need -oldstyle_liblookup to avoid picking up shared libs from
+ # other builds. OSF/1 / Tru64 ld programs look through the entire
+ # library path for shared libs prior to looking through the
+ # entire library path for static libs.
+ CC_LINK_STATIC='$(CC) $(PROG_LIBPATH) -Wl,-oldstyle_liblookup'
# $(PROG_RPATH) is here to handle things like a shared tcl library
RUN_ENV='LD_LIBRARY_PATH=`echo $(PROG_LIBPATH) | sed -e "s/-L//g" -e "s/ /:/g"`:$(PROG_RPATH):/usr/shlib:/usr/ccs/lib:/usr/lib/cmplrs/cc:/usr/lib:/usr/local/lib; export LD_LIBRARY_PATH; _RLD_ROOT=/dev/dummy/d; export _RLD_ROOT;'
;;
@@ -1395,7 +1397,8 @@ AC_DEFUN(AC_LIBRARY_NET, [
# ugliness is necessary:
AC_CHECK_LIB(socket, gethostbyname,
LIBS="-lsocket -lnsl $LIBS",
- AC_CHECK_LIB(resolv, gethostbyname),
+ AC_CHECK_LIB(resolv, gethostbyname,
+ LIBS="-lresolv $LIBS" ; RESOLV_LIB=-lresolv),
-lnsl)
)
)
@@ -1405,20 +1408,43 @@ AC_DEFUN(AC_LIBRARY_NET, [
KRB5_AC_ENABLE_DNS
if test "$enable_dns" = yes ; then
AC_CHECK_FUNC(res_search, , AC_CHECK_LIB(resolv, res_search,
- LIBS="$LIBS -lresolv",
+ LIBS="$LIBS -lresolv" ; RESOLV_LIB=-lresolv,
AC_ERROR(Cannot find resolver support routine res_search in -lresolv.)
))
fi
+ AC_SUBST(RESOLV_LIB)
])
dnl
dnl
dnl KRB5_AC_ENABLE_DNS
dnl
AC_DEFUN(KRB5_AC_ENABLE_DNS, [
+ enable_dns_for_kdc=yes
+ enable_dns_for_realm=no
+
AC_ARG_ENABLE([dns],
-[ --enable-dns enable DNS lookups of Kerberos realm and servers], ,
+[ --enable-dns enable DNS lookups of Kerberos realm and servers],
+[enable_dns_for_kdc="$enable_dns"
+enable_dns_for_realm="$enable_dns"],
[enable_dns=no])
if test "$enable_dns" = yes; then
AC_DEFINE(KRB5_DNS_LOOKUP)
fi
+
+ AC_ARG_ENABLE([dns-for-kdc],
+[ --enable-dns-for-kdc enable DNS lookups of Kerberos servers only])
+ if test "$enable_dns_for_kdc" = yes; then
+ AC_DEFINE(KRB5_DNS_LOOKUP_KDC)
+ fi
+
+ AC_ARG_ENABLE([dns-for-realm],
+[ --enable-dns-for-realm enable DNS lookups of Kerberos realm names only])
+ if test "$enable_dns_for_realm" = yes; then
+ AC_DEFINE(KRB5_DNS_LOOKUP_REALM)
+ fi
+
+ if test "$enable_dns_for_kdc" = yes || test "$enable_dns_for_realm" = yes ; then
+ enable_dns=yes
+ AC_DEFINE(KRB5_DNS_LOOKUP)
+ fi
])
diff --git a/src/kdc/ChangeLog b/src/kdc/ChangeLog
index 700aabc1a7..5d905f9d74 100644
--- a/src/kdc/ChangeLog
+++ b/src/kdc/ChangeLog
@@ -1,3 +1,39 @@
+2000-05-17 Tom Yu <tlyu@mit.edu>
+
+ * kerberos_v4.c (process_v4): Zero out v4_pkt.mbz.
+ (kerberos_v4): Fix handling of APPL_REQUEST messages to deal with
+ ridiculously long realms, etc. Fix up some calls to
+ kerb_err_reply() to be more useful. Set req_*_ptr before any
+ possible calls to kerb_err_reply().
+
+2000-05-11 Nalin Dahyabhai <nalin@redhat.com>
+
+ * kdc_util.c (add_to_transited): Use strncpy/strncat when building
+ data in buffers so as not to overrun "prev", "current", and "exp".
+ * kerberos_v4.c (process_v4): Don't assume that the realm is null-
+ terminated.
+ (set_tgtkey): Truncate realm name if it's too long.
+
+2000-04-28 Ken Raeburn <raeburn@mit.edu>
+ Nalin Dahyabhai <nalin@redhat.com>
+
+ * kdc_util.c (add_to_transited): Use strncpy/strncat when building
+ data in buffers. Fix some limit checks.
+ * kerberos_v4.c (kerb_err_reply): Use strncat so as not to overrun
+ error buffer.
+
+2000-04-22 Ken Raeburn <raeburn@mit.edu>
+
+ * network.c: Include stddef.h.
+ (foreach_localaddr): Check each address against previously used
+ addresses, and skip duplicates, in case multiple interfaces have
+ the same address.
+
+2000-04-21 Ken Raeburn <raeburn@mit.edu>
+
+ * network.c (foreach_localaddr): If called functions fail, drop
+ out of loop and return nonzero.
+
2000-03-14 Ken Raeburn <raeburn@mit.edu>
* sock2p.c: New file.
diff --git a/src/kdc/kdc_util.c b/src/kdc/kdc_util.c
index f5a0016b76..e2c73a0f8f 100644
--- a/src/kdc/kdc_util.c
+++ b/src/kdc/kdc_util.c
@@ -657,26 +657,30 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server)
clst = strlen(current) - 1;
if (current[0] == ' ') {
- strcpy(exp, current+1);
+ strncpy(exp, current+1, sizeof(exp) - 1);
+ exp[sizeof(exp) - 1] = '\0';
}
else if ((current[0] == '/') && (prev[0] == '/')) {
- strcpy(exp, prev);
+ strncpy(exp, prev, sizeof(exp) - 1);
+ exp[sizeof(exp) - 1] = '\0';
if (strlen(exp) + strlen(current) + 1 >= MAX_REALM_LN) {
retval = KRB5KRB_AP_ERR_ILL_CR_TKT;
goto fail;
}
- strcat(exp, current);
+ strncat(exp, current, sizeof(exp) - 1 - strlen(exp));
}
else if (current[clst] == '.') {
- strcpy(exp, current);
- if (strlen(exp) + strlen(current) + 1 >= MAX_REALM_LN) {
+ strncpy(exp, current, sizeof(exp) - 1);
+ exp[sizeof(exp) - 1] = '\0';
+ if (strlen(exp) + strlen(prev) + 1 >= MAX_REALM_LN) {
retval = KRB5KRB_AP_ERR_ILL_CR_TKT;
goto fail;
}
- strcat(exp, prev);
+ strncat(exp, prev, sizeof(exp) - 1 - strlen(exp));
}
else {
- strcpy(exp, current);
+ strncpy(exp, current, sizeof(exp) - 1);
+ exp[sizeof(exp) - 1] = '\0';
}
/* read field into next */
@@ -718,11 +722,12 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server)
if ((next[nlst] != '.') && (next[0] != '/') &&
(pl = subrealm(exp, realm))) {
added = TRUE;
+ current[sizeof(current) - 1] = '\0';
if (strlen(current) + (pl>0?pl:-pl) + 2 >= MAX_REALM_LN) {
retval = KRB5KRB_AP_ERR_ILL_CR_TKT;
goto fail;
}
- strcat(current, ",");
+ strncat(current, ",", sizeof(current) - 1 - strlen(current));
if (pl > 0) {
strncat(current, realm, pl);
}
@@ -762,19 +767,22 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server)
retval = KRB5KRB_AP_ERR_ILL_CR_TKT;
goto fail;
}
- strcat(current, " ");
+ strncat(current, " ", sizeof(current) - 1 - strlen(current));
+ current[sizeof(current) - 1] = '\0';
}
if (strlen(current) + strlen(realm) + 1 >= MAX_REALM_LN) {
retval = KRB5KRB_AP_ERR_ILL_CR_TKT;
goto fail;
}
- strcat(current, realm);
+ strncat(current, realm, sizeof(current) - 1 - strlen(current));
+ current[sizeof(current) - 1] = '\0';
}
if (strlen(current) + (pl>0?pl:-pl) + 2 >= MAX_REALM_LN) {
retval = KRB5KRB_AP_ERR_ILL_CR_TKT;
goto fail;
}
- strcat(current,",");
+ strncat(current,",", sizeof(current) - 1 - strlen(current));
+ current[sizeof(current) - 1] = '\0';
if (pl > 0) {
strncat(current, exp, pl);
}
@@ -798,8 +806,10 @@ add_to_transited(tgt_trans, new_trans, tgs, client, server)
strcat(trans, current);
new_trans->length = strlen(trans) + 1;
- strcpy(prev, exp);
- strcpy(current, next);
+ strncpy(prev, exp, sizeof(prev) - 1);
+ prev[sizeof(prev) - 1] = '\0';
+ strncpy(current, next, sizeof(current) - 1);
+ current[sizeof(current) - 1] = '\0';
}
if (!added) {
diff --git a/src/kdc/kerberos_v4.c b/src/kdc/kerberos_v4.c
index f05452e184..6629c3e35f 100644
--- a/src/kdc/kerberos_v4.c
+++ b/src/kdc/kerberos_v4.c
@@ -233,11 +233,11 @@ krb5_data **resp;
return(retval);
if (!*local_realm) { /* local-realm name already set up */
- /* XXX assumes realm is null-terminated! */
lrealm = master_princ->realm.data;
- if (strlen(lrealm) < sizeof(local_realm))
- strcpy(local_realm, lrealm);
- else
+ if (master_princ->realm.length < sizeof(local_realm)) {
+ memcpy(local_realm, lrealm, master_princ->realm.length);
+ local_realm[master_princ->realm.length] = '\0';
+ } else
retval = KRB5_CONFIG_NOTENUFSPACE;
}
/* convert client_fulladdr to client_sockaddr:
@@ -256,6 +256,7 @@ krb5_data **resp;
return KRB5KRB_ERR_FIELD_TOOLONG;
}
v4_pkt.length = pkt->length;
+ v4_pkt.mbz = 0;
memcpy( v4_pkt.dat, pkt->data, pkt->length);
kerberos_v4( &client_sockaddr, &v4_pkt);
@@ -622,6 +623,9 @@ kerberos_v4(client, pkt)
req_act_vno = req_version;
+ /* set these to point to something safe */
+ req_name_ptr = req_inst_ptr = req_realm_ptr = "";
+
/* check if disabled, but we tell client */
if (kdc_v4 == KDC_V4_DISABLE) {
lt = klog(L_KRB_PERR,
@@ -700,7 +704,7 @@ kerberos_v4(client, pkt)
if ((i = check_princ(req_name_ptr, req_inst_ptr, 0,
&a_name_data, &k5key, 0))) {
- kerb_err_reply(client, pkt, i, lt);
+ kerb_err_reply(client, pkt, i, "check_princ failed");
a_name_data.key_low = a_name_data.key_high = 0;
krb5_free_keyblock_contents(kdc_context, &k5key);
return;
@@ -715,7 +719,7 @@ kerberos_v4(client, pkt)
/* this does all the checking */
if ((i = check_princ(service, instance, lifetime,
&s_name_data, &k5key, 1))) {
- kerb_err_reply(client, pkt, i, lt);
+ kerb_err_reply(client, pkt, i, "check_princ failed");
a_name_data.key_high = a_name_data.key_low = 0;
s_name_data.key_high = s_name_data.key_low = 0;
krb5_free_keyblock_contents(kdc_context, &k5key);
@@ -806,19 +810,40 @@ kerberos_v4(client, pkt)
tk->length = 0;
k_flags = 0; /* various kerberos flags */
+ auth->mbz = 0; /* pkt->mbz already zeroed */
auth->length = 4 + strlen((char *)pkt->dat + 3);
+ if (auth->length + 1 > MAX_KTXT_LEN) {
+ lt = klog(L_KRB_PERR,
+ "APPL request with realm length too long from %s",
+ inet_ntoa(client_host));
+ kerb_err_reply(client, pkt, RD_AP_INCON,
+ "realm length too long");
+ return;
+ }
+
auth->length += (int) *(pkt->dat + auth->length) +
(int) *(pkt->dat + auth->length + 1) + 2;
+ if (auth->length > MAX_KTXT_LEN) {
+ lt = klog(L_KRB_PERR,
+ "APPL request with funky tkt or req_id length from %s",
+ inet_ntoa(client_host));
+ kerb_err_reply(client, pkt, RD_AP_INCON,
+ "funky tkt or req_id length");
+ return;
+ }
memcpy(auth->dat, pkt->dat, auth->length);
strncpy(tktrlm, (char *)auth->dat + 3, REALM_SZ);
+ tktrlm[REALM_SZ-1] = '\0';
kvno = (krb5_kvno)auth->dat[2];
if (set_tgtkey(tktrlm, kvno)) {
lt = klog(L_ERR_UNK,
"FAILED set_tgtkey realm %s, kvno %d. Host: %s ",
tktrlm, kvno, inet_ntoa(client_host));
- kerb_err_reply(client, pkt, kerno, lt);
+ /* no better error code */
+ kerb_err_reply(client, pkt,
+ KERB_ERR_PRINCIPAL_UNKNOWN, lt);
return;
}
kerno = krb_rd_req(auth, "krbtgt", tktrlm, client_host.s_addr,
@@ -863,7 +888,7 @@ kerberos_v4(client, pkt)
kerno = check_princ(service, instance, req_life,
&s_name_data, &k5key, 1);
if (kerno) {
- kerb_err_reply(client, pkt, kerno, lt);
+ kerb_err_reply(client, pkt, kerno, "check_princ failed");
s_name_data.key_high = s_name_data.key_low = 0;
krb5_free_keyblock_contents(kdc_context, &k5key);
return;
@@ -968,7 +993,7 @@ kerb_err_reply(client, pkt, err, string)
static char e_msg[128];
strcpy(e_msg, "\nKerberos error -- ");
- strcat(e_msg, string);
+ strncat(e_msg, string, sizeof(e_msg) - 1 - 19);
cr_err_reply(e_pkt, req_name_ptr, req_inst_ptr, req_realm_ptr,
req_time_ws, err, e_msg);
krb4_sendto(f, (char *) e_pkt->dat, e_pkt->length, 0,
@@ -1127,7 +1152,8 @@ set_tgtkey(r, kvno)
if (!K4KDC_ENCTYPE_OK(k5key.enctype)) {
krb_set_key_krb5(kdc_context, &k5key);
- strcpy(lastrealm, r);
+ strncpy(lastrealm, r, sizeof(lastrealm) - 1);
+ lastrealm[sizeof(lastrealm) - 1] = '\0';
last_kvno = kvno;
} else {
/* unseal tgt key from master key */
@@ -1136,7 +1162,8 @@ set_tgtkey(r, kvno)
kdb_encrypt_key(key, key, master_key,
master_key_schedule, DECRYPT);
krb_set_key((char *) key, 0);
- strcpy(lastrealm, r);
+ strncpy(lastrealm, r, sizeof(lastrealm) - 1);
+ lastrealm[sizeof(lastrealm) - 1] = '\0';
last_kvno = kvno;
}
krb5_free_keyblock_contents(kdc_context, &k5key);
diff --git a/src/kdc/network.c b/src/kdc/network.c
index 502682a863..a91fc95b89 100644
--- a/src/kdc/network.c
+++ b/src/kdc/network.c
@@ -1,7 +1,7 @@
/*
* kdc/network.c
*
- * Copyright 1990 by the Massachusetts Institute of Technology.
+ * Copyright 1990,2000 by the Massachusetts Institute of Technology.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
@@ -35,6 +35,7 @@
#include <sys/ioctl.h>
#include <syslog.h>
+#include <stddef.h>
#include <ctype.h>
#ifdef HAVE_NETINET_IN_H
#include <sys/types.h>
@@ -120,13 +121,14 @@ foreach_localaddr (data, pass1fn, betweenfn, pass2fn)
int (*betweenfn) (void *);
int (*pass2fn) (void *, struct sockaddr *);
{
- struct ifreq *ifr, ifreq;
+ struct ifreq *ifr, ifreq, *ifr2;
struct ifconf ifc;
- int s, code, n, i;
+ int s, code, n, i, j;
int est_if_count = 8, est_ifreq_size;
char *buf = 0;
size_t current_buf_size = 0;
-
+ int fail = 0;
+
s = socket (USE_AF, USE_TYPE, USE_PROTO);
if (s < 0)
return SOCKET_ERRNO;
@@ -184,6 +186,7 @@ foreach_localaddr (data, pass1fn, betweenfn, pass2fn)
continue;
}
+
#ifdef IFF_LOOPBACK
/* None of the current callers want loopback addresses. */
if (ifreq.ifr_flags & IFF_LOOPBACK)
@@ -193,13 +196,32 @@ foreach_localaddr (data, pass1fn, betweenfn, pass2fn)
if (!(ifreq.ifr_flags & IFF_UP))
goto skip;
+ /* Make sure we didn't process this address already. */
+ for (j = 0; j < i; j += ifreq_size(*ifr2)) {
+ ifr2 = (struct ifreq *)((caddr_t) ifc.ifc_buf+j);
+ if (ifr2->ifr_name[0] == 0)
+ continue;
+ if (ifr2->ifr_addr.sa_family == ifr->ifr_addr.sa_family
+ && ifreq_size (*ifr) == ifreq_size (*ifr2)
+ /* Compare address info. If this isn't good enough --
+ i.e., if random padding bytes turn out to differ
+ when the addresses are the same -- then we'll have
+ to do it on a per address family basis. */
+ && !memcmp (&ifr2->ifr_addr.sa_data, &ifr->ifr_addr.sa_data,
+ (ifreq_size (*ifr)
+ - offsetof (struct ifreq, ifr_addr.sa_data))))
+ goto skip;
+ }
+
if ((*pass1fn) (data, &ifr->ifr_addr)) {
- abort ();
+ fail = 1;
+ goto punt;
}
}
if (betweenfn && (*betweenfn)(data)) {
- abort ();
+ fail = 1;
+ goto punt;
}
if (pass2fn)
@@ -211,13 +233,15 @@ foreach_localaddr (data, pass1fn, betweenfn, pass2fn)
continue;
if ((*pass2fn) (data, &ifr->ifr_addr)) {
- abort ();
+ fail = 1;
+ goto punt;
}
}
+ punt:
closesocket(s);
free (buf);
- return 0;
+ return fail;
}
struct socksetup {
diff --git a/src/slave/ChangeLog b/src/slave/ChangeLog
index b8f8e9026c..c60c05efad 100644
--- a/src/slave/ChangeLog
+++ b/src/slave/ChangeLog
@@ -1,3 +1,9 @@
+2000-05-08 Nalin Dahyabhai <nalin@redhat.com>
+
+ * kprop.c (open_connection): New argument indicates output buffer
+ size. Don't overrun it.
+ (get_tickets): Pass size of Errmsg.
+
1999-10-26 Wilfredo Sanchez <tritan@mit.edu>
* Makefile.in: Clean up usage of CFLAGS, CPPFLAGS, DEFS, DEFINES,
diff --git a/src/slave/kprop.c b/src/slave/kprop.c
index 5b6b5969b0..fa32f11a84 100644
--- a/src/slave/kprop.c
+++ b/src/slave/kprop.c
@@ -72,7 +72,7 @@ void get_tickets
static void usage
PROTOTYPE((void));
krb5_error_code open_connection
- PROTOTYPE((char *, int *, char *));
+ PROTOTYPE((char *, int *, char *, int));
void kerberos_authenticate
PROTOTYPE((krb5_context, krb5_auth_context *,
int, krb5_principal, krb5_creds **));
@@ -116,7 +116,7 @@ main(argc, argv)
get_tickets(context);
database_fd = open_database(context, file, &database_size);
- if (retval = open_connection(slave_host, &fd, Errmsg)) {
+ if (retval = open_connection(slave_host, &fd, Errmsg, sizeof(Errmsg))) {
com_err(progname, retval, "%s while opening connection to %s",
Errmsg, slave_host);
exit(1);
@@ -307,10 +307,11 @@ void get_tickets(context)
}
krb5_error_code
-open_connection(host, fd, Errmsg)
+open_connection(host, fd, Errmsg, ErrmsgSz)
char *host;
int *fd;
char *Errmsg;
+ int ErrmsgSz;
{
int s;
krb5_error_code retval;
@@ -331,8 +332,9 @@ open_connection(host, fd, Errmsg)
if(!port) {
sp = getservbyname(KPROP_SERVICE, "tcp");
if (sp == 0) {
- (void) strcpy(Errmsg, KPROP_SERVICE);
- (void) strcat(Errmsg, "/tcp: unknown service");
+ (void) strncpy(Errmsg, KPROP_SERVICE, ErrmsgSz - 1);
+ Errmsg[ErrmsgSz - 1] = '\0';
+ (void) strncat(Errmsg, "/tcp: unknown service", ErrmsgSz - 1 - strlen(Errmsg));
*fd = -1;
return(0);
}
@@ -481,7 +483,8 @@ open_database(context, data_fn, size)
com_err(progname, ENOMEM, "while trying to malloc data_ok_fn");
exit(1);
}
- strcat(strcpy(data_ok_fn, data_fn), ok);
+ strcpy(data_ok_fn, data_fn);
+ strcat(data_ok_fn, ok);
if (stat(data_ok_fn, &stbuf_ok)) {
com_err(progname, errno, "while trying to stat %s",
data_ok_fn);
diff --git a/src/wconfig.c b/src/wconfig.c
index 0671a1ed6b..fdbc0d909b 100644
--- a/src/wconfig.c
+++ b/src/wconfig.c
@@ -76,6 +76,13 @@ int main(int argc, char *argv[])
ignore_len = strlen(ignore_str);
argc--; argv++;
while (*argv && *argv[0] == '-') {
+ wflags[sizeof(wflags) - 1] = '\0';
+ if (strlen (wflags) + 1 + strlen (*argv) > sizeof (wflags) - 1) {
+ fprintf (stderr,
+ "wconfig: argument list too long (internal limit %d)",
+ sizeof (wflags));
+ exit (1);
+ }
if (wflags[0])
strcat(wflags, " ");
strcat(wflags, *argv);