void (*freefn)(void *);
void *data;
} *addrs;
- int naddrs;
- int space;
+ size_t naddrs;
+ size_t space;
};
#define ADDRLIST_INIT { 0, 0, 0 }
extern void krb5int_free_addrlist (struct addrlist *);
#define HASH_Init(x) shsInit(x)
#define HASH_Update(x, buf, sz) shsUpdate(x, (const void*)buf, sz)
#define HASH_Final(x, tdigest) do { \
- int loopvar; \
+ size_t loopvar; \
unsigned char *out2 = (void *)(tdigest); \
HASH_CTX *ctx = (x); \
shsFinal(ctx); \
EXCEP_DECL;
int num = y->slow_k_of_n_thresh;
int source = -1;
- int emax = y->slow_thresh;
+ size_t emax = y->slow_thresh;
size_t entropy = 0;
unsigned i;
const char* krb5int_yarrow_str_error( int err )
{
err = 1-err;
- if ( err < 0 || err >= sizeof( yarrow_str_error ) / sizeof( char* ) )
+ if ( err < 0 ||
+ (unsigned int) err >= sizeof( yarrow_str_error ) / sizeof( char* ) )
{
err = 1-YARROW_FAIL;
}
int slow_k_of_n;
/* current thresholds */
- int slow_thresh;
- int fast_thresh;
+ size_t slow_thresh;
+ size_t fast_thresh;
int slow_k_of_n_thresh;
} Yarrow_CTX;
(OM_uint32 * minor_status,
gss_buffer_set_t *buffer_set)
{
- int i;
+ size_t i;
OM_uint32 minor;
*minor_status = 0;
We used to have a stdio option, but we get more precise control
by using the POSIX I/O functions. */
#define FCC_BUFSIZ 1024
- int valid_bytes;
- int cur_offset;
+ size_t valid_bytes;
+ size_t cur_offset;
char buf[FCC_BUFSIZ];
} krb5_fcc_data;
/* If we read some extra data in advance, and then want to know or
use our "current" position, we need to back up a little. */
if (whence == SEEK_CUR && data->valid_bytes) {
- assert(data->valid_bytes > 0);
assert(data->cur_offset > 0);
assert(data->cur_offset <= data->valid_bytes);
offset -= (data->valid_bytes - data->cur_offset);
int nread, e;
size_t ncopied;
- assert (data->valid_bytes >= 0);
if (data->valid_bytes > 0)
assert(data->cur_offset <= data->valid_bytes);
if (data->valid_bytes == 0
return KRB5_CC_NOMEM;
if (length) {
size_t msize = length;
- if (msize != length) {
+ if (msize != (krb5_ui_4) length) {
free(tmpprinc);
return KRB5_CC_NOMEM;
}
*/
msize = length;
msize += 1;
- if (msize == 0 || msize - 1 != length || length < 0)
+ if (msize == 0 || msize - 1 != (krb5_ui_4) length || length < 0)
return KRB5_CC_NOMEM;
*addrs = ALLOC (msize, krb5_address *);
if (*addrs == NULL)
return KRB5_CC_NOMEM;
keyblock->length = int32;
/* Overflow check. */
- if (keyblock->length != int32)
+ if (keyblock->length != (krb5_ui_4) int32)
return KRB5_CC_NOMEM;
if ( keyblock->length == 0 )
return KRB5_OK;
- keyblock->contents = ALLOC (keyblock->length, krb5_octet);
+ keyblock->contents = malloc(keyblock->length);
if (keyblock->contents == NULL)
return KRB5_CC_NOMEM;
if (len < 0)
return KRB5_CC_NOMEM;
data->length = len;
- if (data->length != len || data->length + 1 == 0)
+ if (data->length != (krb5_ui_4) len || data->length + 1 == 0)
return KRB5_CC_NOMEM;
if (data->length == 0) {
addr->length = int32;
/* Length field is "unsigned int", which may be smaller than 32
bits. */
- if (addr->length != int32)
+ if (addr->length != (krb5_ui_4) int32)
return KRB5_CC_NOMEM; /* XXX */
if (addr->length == 0)
*/
msize = length;
msize += 1;
- if (msize == 0 || msize - 1 != length || length < 0)
+ if (msize == 0 || msize - 1 != (krb5_ui_4) length || length < 0)
return KRB5_CC_NOMEM;
*a = ALLOC (msize, krb5_authdata *);
if (*a == NULL)
a->length = int32;
/* Value could have gotten truncated if int is smaller than 32
bits. */
- if (a->length != int32)
+ if (a->length != (krb5_ui_4) int32)
return KRB5_CC_NOMEM; /* XXX */
if (a->length == 0 )
ret = write(((krb5_fcc_data *)id->data)->file, (char *) buf, len);
if (ret < 0)
return krb5_fcc_interpret(context, errno);
- if (ret != len)
+ if ((unsigned int) ret != len)
return KRB5_CC_WRITE;
return KRB5_OK;
}
kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain);
if (kret)
return kret;
- if (ibuf < 0 || ibuf > remain)
+ if (ibuf < 0 || (krb5_ui_4) ibuf > remain)
return EINVAL;
/* Allocate and unpack the name. */
if (!regcomp(&match_exp, regexp, REG_EXTENDED) &&
!regexec(&match_exp, string, 1, &match_match, 0)) {
if ((match_match.rm_so == 0) &&
- (match_match.rm_eo == strlen(string)))
+ ((unsigned int) match_match.rm_eo == strlen(string)))
kret = 0;
}
regfree(&match_exp);
if (!code) {
/* Success with admin_server but now we need to change the
port number to use DEFAULT_KPASSWD_PORT and the socktype. */
- int i;
+ size_t i;
for (i=0; i<addrlist->naddrs; i++) {
struct addrinfo *a = addrlist->addrs[i].ai;
if (a->ai_family == AF_INET)
len = res_search(host, ds->nclass, ds->ntype,
ds->ansp, ds->ansmax);
#endif
- if (len > maxincr) {
+ if ((size_t) len > maxincr) {
ret = -1;
goto errout;
}
- while (nextincr < len)
+ while (nextincr < (size_t) len)
nextincr *= 2;
if (len < 0 || nextincr > maxincr) {
ret = -1;
char host[MAXDNAME];
#endif
- if (ds->anslen < sizeof(HEADER))
+ if ((size_t) ds->anslen < sizeof(HEADER))
return -1;
hdr = (HEADER *)ds->ansp;
int
krb5int_grow_addrlist (struct addrlist *lp, int nmore)
{
- int i;
- int newspace = lp->space + nmore;
+ size_t i;
+ size_t newspace = lp->space + nmore;
size_t newsize = newspace * sizeof (*lp->addrs);
void *newaddrs;
void
krb5int_free_addrlist (struct addrlist *lp)
{
- int i;
+ size_t i;
for (i = 0; i < lp->naddrs; i++)
if (lp->addrs[i].freefn)
(lp->addrs[i].freefn)(lp->addrs[i].data);
lp->addrs[lp->naddrs].freefn = freefn;
lp->addrs[lp->naddrs].data = data;
lp->naddrs++;
- Tprintf ("\tcount is now %d: ", lp->naddrs);
+ Tprintf ("\tcount is now %lu: ", (unsigned long) lp->naddrs);
print_addrlist(lp);
Tprintf("\n");
return 0;
int socktype, int family)
{
struct addrinfo *addrs, *a, *anext, hint;
- int err;
+ int err, result;
char portbuf[10], secportbuf[10];
void (*freefn)(void *);
#ifdef AI_NUMERICSERV
hint.ai_flags = AI_NUMERICSERV;
#endif
- if (snprintf(portbuf, sizeof(portbuf), "%d", ntohs(port)) >= sizeof(portbuf))
+ result = snprintf(portbuf, sizeof(portbuf), "%d", ntohs(port));
+ if (SNPRINTF_OVERFLOW(result, sizeof(portbuf)))
/* XXX */
return EINVAL;
- if (snprintf(secportbuf, sizeof(secportbuf), "%d", ntohs(secport)) >= sizeof(secportbuf))
+ result = snprintf(secportbuf, sizeof(secportbuf), "%d", ntohs(secport));
+ if (SNPRINTF_OVERFLOW(result, sizeof(secportbuf)))
return EINVAL;
err = getaddrinfo (hostname, portbuf, &hint, &addrs);
if (err) {
Tprintf("stopped with plugin #%d, res=%p\n", i, res);
/* Got something back, yippee. */
- Tprintf("now have %d addrs in list %p\n", addrlist->naddrs, addrlist);
+ Tprintf("now have %lu addrs in list %p\n",
+ (unsigned long) addrlist->naddrs, addrlist);
print_addrlist(addrlist);
free(realmz);
krb5int_free_plugin_dir_data (ptrs);
return((len2 < 0) ? errno : ECONNABORTED);
len = ntohl(len);
- if ((len & VALID_UINT_BITS) != len) /* Overflow size_t??? */
+ if ((len & VALID_UINT_BITS) != (krb5_ui_4) len) /* Overflow size_t??? */
return ENOMEM;
inbuf->length = ilen = (int) len;
static void
print_addrlist (const struct addrlist *a)
{
- int i;
+ size_t i;
dprint("%d{", a->naddrs);
for (i = 0; i < a->naddrs; i++)
dprint("%s%p=%A", i ? "," : "", (void*)a->addrs[i].ai, a->addrs[i].ai);
{
/* Wouldn't it be nice if we could filter out duplicates? The
alloc/free handling makes that pretty difficult though. */
- int err, i;
+ int err;
+ size_t i;
dprint("merging addrlists:\n\tlist1: ");
for (i = 0; i < dest->naddrs; i++)
static int
in_addrlist (struct addrinfo *thisaddr, struct addrlist *list)
{
- int i;
+ size_t i;
for (i = 0; i < list->naddrs; i++) {
if (thisaddr->ai_addrlen == list->addrs[i].ai->ai_addrlen
&& !memcmp(thisaddr->ai_addr, list->addrs[i].ai->ai_addr,
if (tcp_only)
socktype1 = SOCK_STREAM, socktype2 = 0;
- else if (message->length <= context->udp_pref_limit)
+ else if (message->length <= (unsigned int) context->udp_pref_limit)
socktype1 = SOCK_DGRAM, socktype2 = SOCK_STREAM;
else
socktype1 = SOCK_STREAM, socktype2 = SOCK_DGRAM;
if (ai->ai_socktype == SOCK_DGRAM) {
/* Send it now. */
- int ret;
+ ssize_t ret;
sg_buf *sg = &state->x.out.sgbuf[0];
dprint("sending %d bytes on fd %d\n", SG_LEN(sg), state->fd);
ret = send(state->fd, SG_BUF(sg), SG_LEN(sg), 0);
- if (ret != SG_LEN(sg)) {
+ if (ret < 0 || (size_t) ret != SG_LEN(sg)) {
dperror("sendto");
(void) closesocket(state->fd);
state->fd = INVALID_SOCKET;
krb5_data* callback_buffer)
{
sg_buf *sg;
+ ssize_t ret;
dprint("maybe_send(@%p) state=%s type=%s\n", conn,
state_strings[conn->state],
retransmit if a previous attempt timed out. */
sg = &conn->x.out.sgbuf[0];
dprint("sending %d bytes on fd %d\n", SG_LEN(sg), conn->fd);
- if (send(conn->fd, SG_BUF(sg), SG_LEN(sg), 0) != SG_LEN(sg)) {
+ ret = send(conn->fd, SG_BUF(sg), SG_LEN(sg), 0);
+ if (ret < 0 || (size_t) ret != SG_LEN(sg)) {
dperror("send");
/* Keep connection alive, we'll try again next pass.
int ssflags)
{
krb5_error_code e = 0;
- int nwritten, nread;
+ ssize_t nwritten, nread;
if (!(ssflags & (SSF_READ|SSF_WRITE|SSF_EXCEPTION)))
abort();
dprint("wrote %d bytes\n", nwritten);
while (nwritten) {
sg_buf *sgp = conn->x.out.sgp;
- if (nwritten < SG_LEN(sgp)) {
- SG_ADVANCE(sgp, nwritten);
+ if ((size_t) nwritten < SG_LEN(sgp)) {
+ SG_ADVANCE(sgp, (size_t) nwritten);
nwritten = 0;
} else {
- nwritten -= SG_LEN(conn->x.out.sgp);
+ nwritten -= SG_LEN(sgp);
conn->x.out.sgp++;
conn->x.out.sg_count--;
if (conn->x.out.sg_count == 0 && nwritten != 0)
int (*msg_handler)(krb5_context, const krb5_data *, void *),
void *msg_handler_data)
{
- unsigned int i;
int pass;
int delay_this_pass = 2;
krb5_error_code retval;
struct conn_state *conns = NULL;
krb5_data *callback_data = NULL;
- size_t n_conns = 0, host;
+ size_t i, n_conns = 0, host;
struct select_state *sel_state = NULL;
struct timeval now;
int winning_conn = -1, e = 0;
{
c = uctolower(c);
for (; 0 < n; ++u, --n) {
- if (uctolower(*u) == c) {
+ if ((krb5_unicode) uctolower(*u) == c) {
return (krb5_unicode *) u;
}
}
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
register XDR *xdrs;
register int outlen;
- register int inlen;
+ register ssize_t inlen;
GETSOCKNAME_ARG3_TYPE fromlen; /* Assumes recvfrom uses same type */
#ifdef FD_SETSIZE
fd_set readfds;
cu->cu_error.re_errno = errno;
return (cu->cu_error.re_status = RPC_CANTRECV);
}
- if (inlen < sizeof(uint32_t))
+ if ((size_t)inlen < sizeof(uint32_t))
continue;
/* see if reply transaction id matches sent id */
if (*((uint32_t *)(void *)(cu->cu_inbuf)) !=
AUTH *unix_auth = authunix_create_default();
XDR xdr_stream;
register XDR *xdrs = &xdr_stream;
- int outlen, inlen, nets;
+ int outlen, nets;
+ ssize_t inlen;
GETSOCKNAME_ARG3_TYPE fromlen;
SOCKET sock;
int on = 1;
stat = RPC_CANTRECV;
goto done_broad;
}
- if (inlen < sizeof(uint32_t))
+ if ((size_t)inlen < sizeof(uint32_t))
goto recv_again;
/*
* see if reply transaction id matches sent id.
*/
static struct svcauthsw_type {
- u_int flavor;
+ enum_t flavor;
enum auth_stat (*authenticator)(struct svc_req *, struct rpc_msg *,
bool_t *);
} svcauthsw[] = {
goto oops;
/* This could trip if int is 16 bits. */
- if ((unsigned long)(int)code != code)
+ if ((unsigned long)(int)code != (unsigned long)code)
abort ();
#ifdef HAVE_STRERROR_R
cp = get_thread_buffer();
return arr->allocated;
}
-static inline long
+static inline unsigned long
<NAME>_max_size(<NAME> *arr)
{
size_t upper_bound;
upper_bound = SIZE_MAX / sizeof(*arr->elts);
- if (upper_bound > LONG_MAX)
- upper_bound = LONG_MAX;
- return (long) upper_bound;
+ if (upper_bound > ULONG_MAX)
+ upper_bound = ULONG_MAX;
+ return (unsigned long) upper_bound;
}
\f
static inline int
static inline <TYPE> *
<NAME>_getaddr (<NAME> *arr, long idx)
{
- if (idx < 0 || idx >= arr->allocated)
+ if (idx < 0 || (unsigned long) idx >= arr->allocated)
abort();
return arr->elts + idx;
}