summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-02 02:09:25 -0500
committerGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-14 19:20:27 -0500
commite2bfb6322ce9f4323b83469dc06dd1ce1b0f4cf6 (patch)
tree507dab2f064c09996a002624d49c0dfb257a24a9 /lib
parent350312d5db9b0a968bbbbecb37bd600a2da389d0 (diff)
Clean up warnings
Eliminate compiler warnings due to various issues (listed below). This allows Zephyr to build cleanly under GCC versions ranging from 4.1.0 to 4.7.2 with all of the options shown below: -g -O2 -Wall -Werror -Wno-deprecated-declarations -Wmissing-declarations -Wpointer-arith -Wstrict-prototypes -Wshadow -Wextra -Wno-missing-field-initializers -Wno-unused-parameter and, on recent versions, -Wunreachable-code Test builds were done - On Ubuntu 12.10 (Quantal Quetzal) using both MIT Kerberos 1.10.1 and Heimdal 1.6, without krb4 and both with and without C-Ares and Hesiod - On Fedora 14 using Heimdal 0.6, without C-Ares or Hesiod and both with and without krb4 (KTH Kerberos 1.3rc2) - On Fedora Core 3, Fedora Core 5, Fedora 7, and Fedora 10, using Heimdal 0.6 and without C-Ares, Hesiod, or krb4 It also allows clean builds on Solaris 10 under the Sun Studio 12 (9/07) C compiler with the following options: -g -fd -v -errfmt -errhdr=%user -errtags=yes -errwarn=%all -erroff=E_OLD_STYLE_FUNC_DECL,E_ENUM_TYPE_MISMATCH_ARG,E_ARG_INCOMPATIBLE_WITH_ARG ... and under Solaris 9 with the Sun Forte 7 (3/02) C compiler with the above options and -erroff=E_FUNC_HAS_NO_RETURN_STMT. Solaris builds were done with Heimdal 0.6 and without C-Ares, Hesiod, or krb4. The following types of issues are addressed in this change: - Parameters and local variables with the same names as library functions - Parameters and local variables with the same names as globals - Declarations for exported global variables missing from headers - Prototypes for exported functions missing from headers - Missing 'static' on functions that shouldn't be exported - Old-style function declarations - Duplicate declarations - Type mismatches - Unused variables and functions - Uninitialized variables - Forward references to enums - Necessary header files not included - Violations of the aliasing rules, where GCC was able to detect them - Missing braces on if blocks that might be empty - Attempts to do pointer arithmetic on pointers of type void *, which is not permitted in standard C. - An attempt to pass a function pointer via a void * parameter, which is not permitted in standard C. Instead, we now pass a pointer to a structure, which then contains the required function pointer. - Unnecessary inclusion of <krb5_err.h>, which is already included by <krb5.h> when the former exists, and might not be protected against double inclusion, depending on which com_err was used. - Missing include of <com_err.h>, which was masked by the fact that it is included by headers generated by e2fsprogs compile_et - Use of com_err() with a non-constant value in place of the format string, which in every case was a fixed-size buffer in which a message was built using sprintf(!). Both the calls to sprintf and the fixed-size buffers have been removed, in favor of just letting com_err() do the formatting. - Various cases where X library functions expecting a parameter of type wchar_t * were instead passed a parameter of type XChar2b *. The two types look similar, but are not the same and are _not_ interchangeable. - An overly-simplistic configure test which failed to detect existence of <term.h> on Solaris, due to not including <curses.h>. - Using the wrong type for the flags output of krb5_auth_con_getflags() when building against Heimdal. A configure test is added to detect the correct type.
Diffstat (limited to 'lib')
-rw-r--r--lib/ZCkZAut.c15
-rw-r--r--lib/ZExpnRlm.c3
-rw-r--r--lib/ZFmtAuth.c12
-rw-r--r--lib/ZInit.c15
-rw-r--r--lib/ZMakeZcode.c8
-rw-r--r--lib/ZMkAuth.c2
-rw-r--r--lib/ZParseNot.c16
-rw-r--r--lib/ZReadAscii.c2
-rw-r--r--lib/ZVariables.c5
-rw-r--r--lib/Zinternal.c38
-rw-r--r--lib/charset.c51
11 files changed, 87 insertions, 80 deletions
diff --git a/lib/ZCkZAut.c b/lib/ZCkZAut.c
index bc2e88f..4bc3e2a 100644
--- a/lib/ZCkZAut.c
+++ b/lib/ZCkZAut.c
@@ -44,7 +44,7 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
int valid;
char *cksum0_base, *cksum1_base = NULL, *cksum2_base;
char *x;
- unsigned char *asn1_data, *key_data;
+ unsigned char *asn1_data, *key_data, *cksum_data;
int asn1_len, key_len, cksum0_len = 0, cksum1_len = 0, cksum2_len = 0;
#endif
@@ -129,9 +129,9 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
away once Kerberos 4 does. */
if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
key_len == 8 &&
- (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
+ (enctype == (krb5_enctype)ENCTYPE_DES_CBC_CRC ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD4 ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD5)) {
/* try old-format checksum (covers cksum0 only) */
ZChecksum_t our_checksum;
@@ -153,10 +153,11 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
}
/* HOLDING: creds, cksumbuf.data */
- memcpy(cksumbuf.data, cksum0_base, cksum0_len);
+ cksum_data = (unsigned char *)cksumbuf.data;
+ memcpy(cksum_data, cksum0_base, cksum0_len);
if (cksum1_len)
- memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
+ memcpy(cksum_data + cksum0_len, cksum1_base, cksum1_len);
+ memcpy(cksum_data + cksum0_len + cksum1_len,
cksum2_base, cksum2_len);
/* decode zcoded checksum */
diff --git a/lib/ZExpnRlm.c b/lib/ZExpnRlm.c
index 54c2fdb..6f904b6 100644
--- a/lib/ZExpnRlm.c
+++ b/lib/ZExpnRlm.c
@@ -3,8 +3,7 @@
#include <ctype.h>
char *
-ZExpandRealm(realm)
-char *realm;
+ZExpandRealm(char *realm)
{
char *cp1, *cp2;
static char expand[REALM_SZ];
diff --git a/lib/ZFmtAuth.c b/lib/ZFmtAuth.c
index 50e4073..f658f7c 100644
--- a/lib/ZFmtAuth.c
+++ b/lib/ZFmtAuth.c
@@ -38,7 +38,7 @@ ZFormatAuthenticNotice(ZNotice_t *notice,
return (retval);
newnotice.z_checksum =
- (ZChecksum_t)des_quad_cksum((unsigned char *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
+ (ZChecksum_t)des_quad_cksum((void *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
&hdrlen, NULL, NULL)) != ZERR_NONE)
@@ -73,19 +73,23 @@ ZFormatAuthenticNoticeV5(ZNotice_t *notice,
int retval, hdrlen, hdr_adj;
krb5_enctype enctype;
krb5_cksumtype cksumtype;
+#ifdef HAVE_KRB4
int key_len;
+#endif
char *cksum_start, *cstart, *cend;
int cksum_len;
+#ifdef HAVE_KRB4
key_len = Z_keylen(keyblock);
+#endif
retval = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
if (retval)
return (ZAUTH_FAILED);
#ifdef HAVE_KRB4
- if (key_len == 8 && (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
+ if (key_len == 8 && (enctype == (krb5_enctype)ENCTYPE_DES_CBC_CRC ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD4 ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD5)) {
C_Block tmp;
memcpy(&tmp, Z_keydata(keyblock), key_len);
return ZFormatAuthenticNotice(notice, buffer, buffer_len, len,
diff --git a/lib/ZInit.c b/lib/ZInit.c
index 23dd4af..abaa2a4 100644
--- a/lib/ZInit.c
+++ b/lib/ZInit.c
@@ -24,9 +24,6 @@ static const char rcsid_ZInitialize_c[] =
#ifdef HAVE_KRB5
#include <krb5.h>
#endif
-#ifdef HAVE_KRB5_ERR_H
-#include <krb5_err.h>
-#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
@@ -54,7 +51,8 @@ ZInitialize(void)
char addr[4], hostname[NS_MAXDNAME];
struct in_addr servaddr;
struct sockaddr_in sin;
- unsigned int s, sinsize = sizeof(sin);
+ unsigned int sinsize = sizeof(sin);
+ int s;
Code_t code;
ZNotice_t notice;
#ifdef HAVE_KRB5
@@ -244,10 +242,11 @@ struct sockaddr_in ZGetDestAddr (void) {
static int txt_lookup(char *qname, char **result) {
int ret, buflen, left;
void *buf = NULL;
+ void *bufend = NULL;
HEADER *hdr;
unsigned char *p;
char dname[NS_MAXDNAME];
- int queries, answers, stored;
+ int queries, answers;
ret = res_init();
if (ret < 0)
@@ -266,6 +265,7 @@ static int txt_lookup(char *qname, char **result) {
buflen = ret;
left = ret;
+ bufend = buflen + (unsigned char *)buf;
hdr = (HEADER *)buf;
p = buf;
@@ -275,7 +275,7 @@ static int txt_lookup(char *qname, char **result) {
left -= sizeof (HEADER);
while (queries--) {
- ret = dn_expand(buf, buf + buflen, p, dname, sizeof dname);
+ ret = dn_expand(buf, bufend, p, dname, sizeof dname);
if (ret < 0 || (ret + 4) > left)
return -1;
p += ret + 4;
@@ -285,11 +285,10 @@ static int txt_lookup(char *qname, char **result) {
if (!ret || !answers)
return -1;
- stored = 0;
while (answers--) {
int class, type;
- ret = dn_expand(buf, buf + buflen, p, dname, sizeof dname);
+ ret = dn_expand(buf, bufend, p, dname, sizeof dname);
if (ret < 0 || ret > left)
return -1;
p += ret;
diff --git a/lib/ZMakeZcode.c b/lib/ZMakeZcode.c
index 85c6f9d..63397a5 100644
--- a/lib/ZMakeZcode.c
+++ b/lib/ZMakeZcode.c
@@ -54,16 +54,16 @@ ZMakeZcode(register char *ptr,
case 0x00:
if (len < 3)
return ZERR_FIELDLEN;
- *ptr++ = 0xff;
- *ptr++ = 0xf0;
+ *(unsigned char *)ptr++ = 0xff;
+ *(unsigned char *)ptr++ = 0xf0;
len -= 2;
continue;
case 0xff:
if (len < 3)
return ZERR_FIELDLEN;
- *ptr++ = 0xff;
- *ptr++ = 0xf1;
+ *(unsigned char *)ptr++ = 0xff;
+ *(unsigned char *)ptr++ = 0xf1;
len -= 2;
continue;
diff --git a/lib/ZMkAuth.c b/lib/ZMkAuth.c
index 8b74570..8989481 100644
--- a/lib/ZMkAuth.c
+++ b/lib/ZMkAuth.c
@@ -123,7 +123,7 @@ ZMakeZcodeRealmAuthentication(register ZNotice_t *notice,
krb5_auth_context authctx;
krb5_data *authent;
char *cksum_start, *cstart, *cend;
- int cksum_len, zcode_len, phdr_adj;
+ int cksum_len, zcode_len = 0, phdr_adj;
notice->z_ascii_authent = NULL;
diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c
index 9143a12..48311b5 100644
--- a/lib/ZParseNot.c
+++ b/lib/ZParseNot.c
@@ -242,7 +242,7 @@ ZParseNotice(char *buffer,
/* we will take it on faith that ipv6 addresses are longer than ipv4
addresses */
unsigned char addrbuf[sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)];
- int len;
+ int alen;
/* because we're paranoid about naughtily misformatted packets */
if (memchr(ptr, '\0', end - ptr) == NULL)
@@ -250,24 +250,24 @@ ZParseNotice(char *buffer,
if (*ptr == 'Z') {
if (ZReadZcode((unsigned char *)ptr, addrbuf,
- sizeof(addrbuf), &len) == ZERR_BADFIELD)
+ sizeof(addrbuf), &alen) == ZERR_BADFIELD)
BAD_PACKET("parsing Zcode address");
} else {
- len = sizeof(notice->z_sender_sockaddr.ip4.sin_addr);
+ alen = sizeof(notice->z_sender_sockaddr.ip4.sin_addr);
if (ZReadAscii(ptr, end - ptr, (unsigned char *)addrbuf,
- len) == ZERR_BADFIELD)
+ alen) == ZERR_BADFIELD)
BAD_PACKET("parsing NetASCII address");
}
- if (len == sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)) {
+ if (alen == sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)) {
notice->z_sender_sockaddr.ip6.sin6_family = AF_INET6;
- memcpy(&notice->z_sender_sockaddr.ip6.sin6_addr, addrbuf, len);
+ memcpy(&notice->z_sender_sockaddr.ip6.sin6_addr, addrbuf, alen);
#ifdef HAVE_SOCKADDR_IN6_SIN6_LEN
notice->z_sender_sockaddr.ip6.sin6_len = sizeof(notice->z_sender_sockaddr.ip6);
#endif
- } else if (len == sizeof(notice->z_sender_sockaddr.ip4.sin_addr)) {
+ } else if (alen == sizeof(notice->z_sender_sockaddr.ip4.sin_addr)) {
notice->z_sender_sockaddr.ip4.sin_family = AF_INET;
- memcpy(&notice->z_sender_sockaddr.ip4.sin_addr, addrbuf, len);
+ memcpy(&notice->z_sender_sockaddr.ip4.sin_addr, addrbuf, alen);
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
notice->z_sender_sockaddr.ip4.sin_len = sizeof(notice->z_sender_sockaddr.ip4);
#endif
diff --git a/lib/ZReadAscii.c b/lib/ZReadAscii.c
index 49aaa58..69c1ecd 100644
--- a/lib/ZReadAscii.c
+++ b/lib/ZReadAscii.c
@@ -28,7 +28,7 @@ ZReadAscii(char *ptr,
int i;
unsigned int hexbyte;
register int c1, c2;
- register unsigned int temp;
+ register int temp;
for (i=0;i<num;i++) {
if (len >= 1 && *ptr == ' ') {
diff --git a/lib/ZVariables.c b/lib/ZVariables.c
index 6f06bab..fb8c9e5 100644
--- a/lib/ZVariables.c
+++ b/lib/ZVariables.c
@@ -168,7 +168,7 @@ static int
varline(char *bfr, char *var)
{
register char *cp;
-
+ size_t namelen;
if (!bfr[0] || bfr[0] == '#') /* comment or null line */
return (0);
@@ -179,7 +179,8 @@ varline(char *bfr, char *var)
#define max(a,b) ((a > b) ? (a) : (b))
- if (strncasecmp(bfr, var, max(strlen(var),cp - bfr)))
+ namelen = cp - bfr;
+ if (strncasecmp(bfr, var, max(strlen(var), namelen)))
return(0); /* var is not the var in
bfr ==> no match */
diff --git a/lib/Zinternal.c b/lib/Zinternal.c
index 7e3e904..0f692f3 100644
--- a/lib/Zinternal.c
+++ b/lib/Zinternal.c
@@ -87,7 +87,7 @@ Code_t
Z_krb5_lookup_cksumtype(krb5_enctype e,
krb5_cksumtype *c)
{
- int i;
+ unsigned int i;
for (i = 0; i < N_CKSUM_MAP; i++) {
if (cksum_map[i].e == e) {
@@ -188,12 +188,12 @@ int
Z_PacketWaiting(void)
{
struct timeval tv;
- fd_set read;
+ fd_set readfds;
tv.tv_sec = tv.tv_usec = 0;
- FD_ZERO(&read);
- FD_SET(ZGetFD(), &read);
- return (select(ZGetFD() + 1, &read, NULL, NULL, &tv));
+ FD_ZERO(&readfds);
+ FD_SET(ZGetFD(), &readfds);
+ return (select(ZGetFD() + 1, &readfds, NULL, NULL, &tv));
}
@@ -254,7 +254,8 @@ Z_SearchQueue(ZUnique_Id_t *uid,
if (ZCompareUID(uid, &qptr->uid) && qptr->kind == kind)
return (qptr);
next = qptr->next;
- if (qptr->timep && (qptr->timep+Z_NOTICETIMELIMIT < tv.tv_sec))
+ if (qptr->timep &&
+ (qptr->timep+Z_NOTICETIMELIMIT < (unsigned long)tv.tv_sec))
Z_RemQueue(qptr);
qptr = next;
}
@@ -1154,9 +1155,9 @@ Z_SendFragmentedNotice(ZNotice_t *notice,
Code_t Z_XmitFragment(ZNotice_t *notice,
char *buf,
int len,
- int wait)
+ int waitforack)
{
- return(ZSendPacket(buf, len, wait));
+ return(ZSendPacket(buf, len, waitforack));
}
/* For debugging printing */
@@ -1285,14 +1286,13 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
int cksum1_len; /* length of part after checksum */
krb5_data cksumbuf;
krb5_data cksum;
- unsigned char *key_data;
- int key_len;
+ unsigned char *cksum_data;
+ unsigned int cksum_data_len;
+ char *cksum_out_data;
krb5_enctype enctype;
krb5_cksumtype cksumtype;
Code_t result;
- key_data = Z_keydata(keyblock);
- key_len = Z_keylen(keyblock);
result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
if (result)
return (ZAUTH_FAILED);
@@ -1306,19 +1306,22 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
cksumbuf.data = malloc(cksumbuf.length);
if (!cksumbuf.data)
return ENOMEM;
- memcpy(cksumbuf.data, cksum_start, cksum0_len);
- memcpy(cksumbuf.data + cksum0_len, cend, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
+ cksum_data = (unsigned char *)cksumbuf.data;
+ memcpy(cksum_data, cksum_start, cksum0_len);
+ memcpy(cksum_data + cksum0_len, cend, cksum1_len);
+ memcpy(cksum_data + cksum0_len + cksum1_len,
notice->z_message, notice->z_message_len);
/* compute the checksum */
result = Z_Checksum(&cksumbuf, keyblock, cksumtype,
from_server ? Z_KEYUSAGE_SRV_CKSUM
: Z_KEYUSAGE_CLT_CKSUM,
- (char **)&cksum.data, &cksum.length);
+ &cksum_out_data, &cksum_data_len);
if (result) {
free(cksumbuf.data);
return result;
}
+ cksum.data = cksum_out_data;
+ cksum.length = cksum_data_len;
/*
* OK.... we can zcode to a space starting at 'cstart',
@@ -1332,7 +1335,7 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
free(cksum.data);
if (!result) {
int zcode_len = strlen(cstart) + 1;
- memcpy(cstart + zcode_len, cksumbuf.data + cksum0_len, cksum1_len);
+ memcpy(cstart + zcode_len, cksum_data + cksum0_len, cksum1_len);
*length_adjust = zcode_len - cksum_len + (cksum0_len + cksum1_len);
}
free(cksumbuf.data);
@@ -1366,7 +1369,6 @@ Z_krb5_verify_cksum(krb5_keyblock *keyblock,
#else
krb5_crypto cryptctx;
Checksum checksum;
- size_t xlen;
#endif
memset(&checksum, 0, sizeof(checksum));
diff --git a/lib/charset.c b/lib/charset.c
index 34806e3..14aec28 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -104,32 +104,33 @@ ZTransliterate(char *in, int inlen, char *inset, char *outset, char **out, int *
free(outset_t);
- if (ih != (iconv_t)-1) {
- size = inlen; /* doubling this should be enough, but.. */
- do {
- size = size * 2;
-
- *out = malloc(size);
- if (*out == NULL) {
- iconv_close(ih);
- return errno;
- }
-
- inleft = inlen;
- outleft = size;
-
- inp = in;
- outp = *out;
-
- retval = iconv(ih, &inp, &inleft, &outp, &outleft);
- if (retval < 0)
- free(*out);
- } while (retval < 0 && errno == E2BIG);
-
- iconv_close(ih);
- }
+ if (ih == (iconv_t)-1)
+ return errno;
+
+ size = inlen; /* doubling this should be enough, but.. */
+ do {
+ size = size * 2;
+
+ *out = malloc(size);
+ if (*out == NULL) {
+ iconv_close(ih);
+ return errno;
+ }
+
+ inleft = inlen;
+ outleft = size;
+
+ inp = in;
+ outp = *out;
+
+ retval = iconv(ih, &inp, &inleft, &outp, &outleft);
+ if (retval < 0)
+ free(*out);
+ } while (retval < 0 && errno == E2BIG);
+
+ iconv_close(ih);
- if (ih == (iconv_t)-1 || retval < 0)
+ if (retval < 0)
return errno;
*outlen = size - outleft;