+2001-12-06 Ezra Peisach <epeisach@mit.edu>
+
+ * krcp.c, krlogin.c, krlogind.c, krsh.c, krshd.c, login.c,
+ setenv.c, v4rcp.c: Signed v.s unsigned int cleanup.
+
+ * defines.h: rcmd_stream_{read,write} take size_t as length argument.
+
+ * kcmd.c: Use GETSOCKNAME_ARG3_TYPE instead of assuming int. input
+ and output handler take size_t as length argument instead of
+ int. Other signed vs. unsigned fixes.
+
+ * configure.in: Add KRB5_GETSOCKNAME_ARGS.
+
2001-11-06 Sam Hartman <hartmans@mit.edu>
* kcmd.c: Define storage for our key usages
CHECK_WAIT_TYPE
AC_CHECK_HEADER(termios.h,AC_CHECK_FUNC(cfsetispeed,AC_DEFINE(POSIX_TERMIOS)))
CHECK_UTMP
+KRB5_GETSOCKNAME_ARGS
dnl
dnl Check for where the BSD rlogin, rcp, and rsh programs live.
dnl
enum kcmd_proto *protonum /* input and output */
);
-extern int rcmd_stream_read (int fd, char *buf, int len, int secondary);
-extern int rcmd_stream_write (int fd, char *buf, int len, int secondary);
+extern int rcmd_stream_read (int fd, char *buf, size_t len, int secondary);
+extern int rcmd_stream_write (int fd, char *buf, size_t len, int secondary);
extern int getport (int *);
extern void rcmd_stream_init_krb5 (krb5_keyblock *in_keyblock,
#define KCMD_KEYUSAGE 1026 /* Key usage used with 3des or any old-protocol enctype*/
/* New protocol enctypes that use cipher state have keyusage defined later*/
+#ifndef GETSOCKNAME_ARG3_TYPE
+#define GETSOCKNAME_ARG3_TYPE int
+#endif
/*
* Note that the encrypted rlogin packets take the form of a four-byte
static krb5_data encivec_i[2], encivec_o[2];
static krb5_keyblock *keyblock; /* key for encrypt/decrypt */
-static int (*input)(int, char *, int, int);
-static int (*output)(int, char *, int, int);
+static int (*input)(int, char *, size_t, int);
+static int (*output)(int, char *, size_t, int);
static char storage[2*RCMD_BUFSIZ]; /* storage for the decryption */
-static int nstored = 0;
+static size_t nstored = 0;
static char *store_ptr = storage;
-static int twrite(int, char *, int, int);
-static int v5_des_read(int, char *, int, int),
- v5_des_write(int, char *, int, int);
+static int twrite(int, char *, size_t, int);
+static int v5_des_read(int, char *, size_t, int),
+ v5_des_write(int, char *, size_t, int);
#ifdef KRB5_KRB4_COMPAT
-static int v4_des_read(int, char *, int, int),
- v4_des_write(int, char *, int, int);
+static int v4_des_read(int, char *, size_t, int),
+ v4_des_write(int, char *, size_t, int);
static C_Block v4_session;
static int right_justify;
#endif
krb5_error_code status;
krb5_ap_rep_enc_part *rep_ret;
krb5_error *error = 0;
- int sin_len;
+ GETSOCKNAME_ARG3_TYPE sin_len;
krb5_ccache cc;
krb5_data outbuf;
krb5_flags options = authopts;
if (!suppress_err) {
fprintf(stderr, "Server returned error code %d (%s)\n",
error->error,
- error_message(ERROR_TABLE_BASE_krb5 + error->error));
+ error_message(ERROR_TABLE_BASE_krb5 +
+ (int) error->error));
if (error->text.length) {
fprintf(stderr, "Error text sent from server: %s\n",
error->text.data);
char c;
int lport = START_PORT;
struct hostent *hp;
- int rc, sin_len;
+ int rc;
+ GETSOCKNAME_ARG3_TYPE sin_len;
char *host_save;
int status;
cc = 'l';
(void) write(2, &cc, 1);
if (p != check)
- (void) write(2, check, p - check);
+ (void) write(2, check, (unsigned) (p - check));
}
(void) write(2, &c, 1);
{
struct sockaddr_in sockin;
int s;
- int len = sizeof(sockin);
+ GETSOCKNAME_ARG3_TYPE len = sizeof(sockin);
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
}
static int
-normal_read (int fd, char *buf, int len, int secondary)
+normal_read (int fd, char *buf, size_t len, int secondary)
{
return read (fd, buf, len);
}
int rcmd_stream_read(fd, buf, len, sec)
int fd;
register char *buf;
- int len;
+ size_t len;
int sec;
{
return (*input)(fd, buf, len, sec);
int rcmd_stream_write(fd, buf, len, sec)
int fd;
register char *buf;
- int len;
+ size_t len;
int sec;
{
return (*output)(fd, buf, len, sec);
static int twrite(fd, buf, len, secondary)
int fd;
char *buf;
- int len;
+ size_t len;
int secondary;
{
return write((fd == 0) ? 1 : fd, buf, len);
static int v5_des_read(fd, buf, len, secondary)
int fd;
char *buf;
- int len;
+ size_t len;
int secondary;
{
int nreturned = 0;
static int v5_des_write(fd, buf, len, secondary)
int fd;
char *buf;
- int len;
+ size_t len;
int secondary;
{
krb5_data plain;
v4_des_read(fd, buf, len, secondary)
int fd;
char *buf;
-int len;
+size_t len;
int secondary;
{
int nreturned = 0;
}
(void) pcbc_encrypt((des_cblock *) des_inbuf,
(des_cblock *) storage,
- (net_len < 8) ? 8 : net_len,
+ (int) ((net_len < 8) ? 8 : net_len),
v4_schedule,
&v4_session,
DECRYPT);
v4_des_write(fd, buf, len, secondary)
int fd;
char *buf;
-int len;
+size_t len;
int secondary;
{
static char garbage_buf[8];
}
(void) pcbc_encrypt((des_cblock *) ((len < 8) ? garbage_buf : buf),
(des_cblock *) (des_outpkt+4),
- (len < 8) ? 8 : len,
+ (int) ((len < 8) ? 8 : len),
v4_schedule,
&v4_session,
ENCRYPT);
int port = 0;
struct buffer {
- int cnt;
+ unsigned int cnt;
char *buf;
};
char *targ, *host, *src;
char *suser, *tuser, *thost;
int i;
- int cmdsiz = 30;
+ unsigned int cmdsiz = 30;
char buf[RCP_BUFSIZ], cmdbuf[30];
char *cmd = cmdbuf;
struct servent *sp;
struct stat stb;
static struct buffer buffer;
struct buffer *bp;
- int x, readerr, f, amt;
+ int x, readerr, f;
+ unsigned int amt;
off_t i;
char buf[RCP_BUFSIZ];
*cp++ = c;
} while (cp < &rbuf[RCP_BUFSIZ] && c != '\n');
if (iamremote == 0)
- (void) write(2, rbuf, cp - rbuf);
+ (void) write(2, rbuf, (unsigned) (cp - rbuf));
errs++;
if (resp == 1)
return (-1);
mode_t mask = umask(0);
off_t i, j;
char *targ, *whopp, *cp;
- int of, wrerr, exists, first, count, amt, size;
+ int of, wrerr, exists, first;
+ off_t size;
+ unsigned int amt, count;
struct buffer *bp;
static struct buffer buffer;
struct stat stb;
static int reader(int);
static void doit(int);
#endif
-static int control(char *, int);
+static int control(char *, unsigned int);
static void sendwindow(void);
static void stop(int), echo(int);
static void writer(void), done(int);
}
if (!got_esc) {
- if (rcmd_stream_write(rem, buf, n_read, 0) == 0) {
+ if (rcmd_stream_write(rem, buf, (unsigned) n_read, 0) == 0) {
prf("line gone");
break;
}
/* This next test is necessary to avoid sending 0 bytes of data
in the event that we got just a cmdchar */
if (n_read > 1) {
- if (rcmd_stream_write(rem, buf, n_read-1, 0) == 0) {
+ if (rcmd_stream_write(rem, buf, (unsigned) (n_read-1), 0) == 0) {
prf("line gone");
break;
}
static char *data_start = tbuf;
static char *data_end = tbuf;
static int bol = 1;
- int return_length = 0;
+ unsigned int return_length = 0;
char c;
/* if we have no data buffered, get more */
*p++ = c;
*p++ = '\r';
*p++ = '\n';
- (void) write(1, buf, p - buf);
+ (void) write(1, buf, (unsigned) (p - buf));
}
static void sendwindow()
{
char obuf[4 + sizeof (struct winsize)];
- struct winsize *wp = (struct winsize *)(obuf+4);
+ struct winsize *wp = (struct winsize *)(void *)(obuf+4);
obuf[0] = 0377;
obuf[1] = 0377;
static int control(cp, n)
char *cp;
- int n;
+ unsigned int n;
{
if ((n >= 5) && (cp[2] == 'o') && (cp[3] == 'o')) {
if (server_message(cp[4]))
#endif
{
fd_set readset, excset, writeset;
- int n, remaining, left;
+ int n, remaining;
+ unsigned int left;
char *bufp = rcvbuf;
char *cp;
cp[1] == '\377') {
left = (rcvbuf+rcvcnt) - cp;
n = control(cp, left);
+ /* |n| <= left */
if (n < 0) {
left -= (-n);
rcvcnt = 0;
krb5_principal principal;
{
char *def_realm;
- int realm_length;
+ unsigned int realm_length;
int retval;
realm_length = krb5_princ_realm(bsd_context, principal)->length;
cc += strlen(*ap) + 1;
if (encrypt_flag)
cc += 3;
- cp = args = (char *) malloc(cc);
+ cp = args = (char *) malloc((unsigned) cc);
if (encrypt_flag) {
strcpy(args, "-x ");
cp += 3;
if ((errno != EWOULDBLOCK) && (errno != EAGAIN))
FD_CLR(rfd2, &readfrom);
} else
- (void) write(2, buf, cc);
+ (void) write(2, buf, (unsigned) cc);
}
if (FD_ISSET(rem, &ready)) {
errno = 0;
if ((errno != EWOULDBLOCK) && (errno != EAGAIN))
FD_CLR(rem, &readfrom);
} else
- (void) write(1, buf, cc);
+ (void) write(1, buf, (unsigned) cc);
}
} while (FD_ISSET(rem, &readfrom) || FD_ISSET(rfd2, &readfrom));
if (nflag == 0)
shutdown(s, 1+1);
FD_CLR(pv[0], &readfrom);
} else {
- (void) rcmd_stream_write(s, buf, cc, 1);
+ (void) rcmd_stream_write(s, buf, (unsigned) cc, 1);
}
}
if (FD_ISSET(pw[0], &ready)) {
shutdown(f, 1+1);
FD_CLR(pw[0], &readfrom);
} else {
- (void) rcmd_stream_write(f, buf, cc, 0);
+ (void) rcmd_stream_write(f, buf, (unsigned) cc, 0);
}
}
if (port&&FD_ISSET(s, &ready)) {
FD_CLR(f, &readfrom);
} else {
int wcc;
- wcc = write(px[1], buf, cc);
+ wcc = write(px[1], buf, (unsigned) cc);
if (wcc == -1) {
/* pipe closed, don't read any more */
/* might check for EPIPE */
krb5_principal principal;
{
char *def_realm;
- int realm_length;
+ unsigned int realm_length;
int retval;
realm_length = krb5_princ_realm(bsd_context, principal)->length;
if ((fd = open(NOLOGIN, O_RDONLY, 0)) >= 0) {
while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
- (void)write(fileno(stdout), tbuf, nchars);
+ (void)write(fileno(stdout), tbuf, (unsigned) nchars);
sleepexit(0);
}
}
int *offset;
{
extern char **environ;
- register int len;
+ register unsigned int len;
register char **P, *C;
for (C = name, len = 0; *C && *C != '='; ++C, ++len);
static int kstream_read(krem, buf, len)
kstream krem;
char *buf;
- int len;
+ unsigned int len;
{
if(krem->encrypting) {
/* when we get a length, we have to read the whole block. However,
int cc;
unsigned char clen[4];
unsigned int x = 0;
- int sz, off;
+ unsigned int sz, off;
cc = read(krem->read_fd, clen, 4);
if (cc != 4) return cc;
x <<= 8; x += clen[1] & 0xff;
x <<= 8; x += clen[2] & 0xff;
x <<= 8; x += clen[3] & 0xff;
- sz = (x + 7) & ~7;
+ sz = (x + 7) & (~7U);
if (krem->retbuflen < sz) {
if (krem->retbuflen == 0)
/* decrypt it */
des_pcbc_encrypt ((des_cblock *)krem->retbuf,
(des_cblock *)krem->retbuf,
- sz, *krem->sched, krem->ivec,
+ (int) sz, *krem->sched, krem->ivec,
DECRYPT);
/* now retbuf has sz bytes, return len or x of them to the user */
static int kstream_write(krem, buf, len)
kstream krem;
char *buf;
- int len;
+ unsigned int len;
{
if (krem->encrypting) {
unsigned long x;
int st;
- int outlen = (len + 7) & (~7);
+ unsigned int outlen = (len + 7) & (~7U);
if (krem->writelen < outlen) {
if (krem->writelen == 0) {
krem->writelen = outlen;
}
- outlen = (len + 7) & (~7);
+ outlen = (len + 7) & (~7U);
memcpy(krem->inbuf, buf, len);
krb5_random_confounder(outlen-len, krem->inbuf+len);
if (x)
abort ();
/* memset(outbuf+4+4, 0x42, BUFSIZ); */
- st = des_pcbc_encrypt ((des_cblock *)buf, (des_cblock *)(krem->outbuf+4+4), outlen,
+ st = des_pcbc_encrypt ((des_cblock *)buf, (des_cblock *)(krem->outbuf+4+4),
+ (int) outlen,
*krem->sched, krem->ivec, ENCRYPT);
if (st) abort();
struct stat stb;
static struct buffer buffer;
struct buffer *bp;
- int x, readerr, f, amt;
+ int x, readerr, f;
+ unsigned int amt;
off_t i;
char buf[BUFSIZ];
*cp++ = c;
} while (cp < &rbuf[BUFSIZ] && c != '\n');
if (iamremote == 0)
- (void) write(2, rbuf, cp - rbuf);
+ (void) write(2, rbuf, (unsigned) (cp - rbuf));
errs++;
if (resp == 1)
return (-1);
{
off_t i, j;
char *targ, *whopp, *cp;
- int of, mode, wrerr, exists, first, count, amt;
+ int of, wrerr, exists, first, amt;
+ mode_t mode;
+ unsigned int count;
off_t size;
struct buffer *bp;
static struct buffer buffer;
struct stat stb;
int targisdir = 0;
- int mask = umask(0);
+ mode_t mask = umask(0);
char *myargv[1];
char cmdbuf[BUFSIZ], nambuf[BUFSIZ];
int setimes = 0;