Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.
We turn on a few extra warnings and fix the fallout that occurs when building with --enable-developer. Note that we get different warnings on different machines and so this will be a work in progress. So far, we have built on NetBSD/amd64 5.99.64 (which uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3). Notably, we fixed 1. a lot of missing structure initialisers, 2. unchecked return values for functions that glibc marks as __attribute__((warn-unused-result)), 3. made minor modifications to slc and asn1_compile which can generate code which generates warnings, and 4. a few stragglers here and there. We turned off the extended warnings for many programs in appl/ as they are nearing the end of their useful lifetime, e.g. rsh, rcp, popper, ftp and telnet. Interestingly, glibc's strncmp() macro needed to be worked around whereas the function calls did not. We have not yet tried this on 32 bit platforms, so there will be a few more warnings when we do.
This commit is contained in:
@@ -181,10 +181,11 @@ configure(krb5_context context, int argc, char **argv, int *optidx)
|
||||
|
||||
{
|
||||
char **files;
|
||||
int aret;
|
||||
|
||||
if (config_file == NULL) {
|
||||
asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context));
|
||||
if (config_file == NULL)
|
||||
aret = asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context));
|
||||
if (aret == -1 || config_file == NULL)
|
||||
errx(1, "out of memory");
|
||||
}
|
||||
|
||||
|
23
kdc/digest.c
23
kdc/digest.c
@@ -406,11 +406,12 @@ _kdc_do_digest(krb5_context context,
|
||||
|
||||
if (ireq.u.init.channel) {
|
||||
char *s;
|
||||
int aret;
|
||||
|
||||
asprintf(&s, "%s-%s:%s", r.u.initReply.nonce,
|
||||
ireq.u.init.channel->cb_type,
|
||||
ireq.u.init.channel->cb_binding);
|
||||
if (s == NULL) {
|
||||
aret = asprintf(&s, "%s-%s:%s", r.u.initReply.nonce,
|
||||
ireq.u.init.channel->cb_type,
|
||||
ireq.u.init.channel->cb_binding);
|
||||
if (aret == -1 || s == NULL) {
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret,
|
||||
"Failed to allocate channel binding");
|
||||
@@ -427,6 +428,8 @@ _kdc_do_digest(krb5_context context,
|
||||
}
|
||||
|
||||
if (strcasecmp(ireq.u.init.type, "CHAP") == 0) {
|
||||
int aret;
|
||||
|
||||
r.u.initReply.identifier =
|
||||
malloc(sizeof(*r.u.initReply.identifier));
|
||||
if (r.u.initReply.identifier == NULL) {
|
||||
@@ -435,8 +438,8 @@ _kdc_do_digest(krb5_context context,
|
||||
goto out;
|
||||
}
|
||||
|
||||
asprintf(r.u.initReply.identifier, "%02X", identifier & 0xff);
|
||||
if (*r.u.initReply.identifier == NULL) {
|
||||
aret = asprintf(r.u.initReply.identifier, "%02X", identifier&0xff);
|
||||
if (aret == -1 || *r.u.initReply.identifier == NULL) {
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
@@ -997,10 +1000,12 @@ _kdc_do_digest(krb5_context context,
|
||||
}
|
||||
|
||||
} else {
|
||||
int aret;
|
||||
|
||||
r.element = choice_DigestRepInner_error;
|
||||
asprintf(&r.u.error.reason, "Unsupported digest type %s",
|
||||
ireq.u.digestRequest.type);
|
||||
if (r.u.error.reason == NULL) {
|
||||
aret = asprintf(&r.u.error.reason, "Unsupported digest type %s",
|
||||
ireq.u.digestRequest.type);
|
||||
if (aret == -1 || r.u.error.reason == NULL) {
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
|
@@ -145,7 +145,7 @@ main(int argc, char **argv)
|
||||
if(getpeername(sock, sa, &sin_len) < 0)
|
||||
krb5_err(context, 1, errno, "getpeername");
|
||||
|
||||
if (inet_ntop(sa->sa_family,
|
||||
if (inet_ntop(ss.ss_family,
|
||||
socket_get_address (sa),
|
||||
addr_name,
|
||||
sizeof(addr_name)) == NULL)
|
||||
@@ -207,7 +207,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if(!print_dump) {
|
||||
asprintf(&tmp_db, "%s~", database);
|
||||
int aret;
|
||||
|
||||
aret = asprintf(&tmp_db, "%s~", database);
|
||||
if (aret == -1)
|
||||
krb5_errx(context, 1, "hdb_create: out of memory");
|
||||
|
||||
ret = hdb_create(context, &db, tmp_db);
|
||||
if(ret)
|
||||
|
@@ -37,11 +37,11 @@ static int version_flag;
|
||||
static int help_flag;
|
||||
|
||||
struct getargs args[] = {
|
||||
{ "version", 0, arg_flag, &version_flag },
|
||||
{ "help", 'h', arg_flag, &help_flag }
|
||||
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
|
||||
{ "help", 'h', arg_flag, &help_flag, NULL, NULL }
|
||||
};
|
||||
|
||||
const static int num_args = sizeof(args) / sizeof(args[0]);
|
||||
static const int num_args = sizeof(args) / sizeof(args[0]);
|
||||
|
||||
static void
|
||||
usage(int ret)
|
||||
|
26
kdc/kstash.c
26
kdc/kstash.c
@@ -66,6 +66,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
char buf[1024];
|
||||
krb5_error_code ret;
|
||||
int aret;
|
||||
|
||||
krb5_enctype enctype;
|
||||
|
||||
@@ -84,8 +85,11 @@ main(int argc, char **argv)
|
||||
krb5_errx(context, 1, "random-key and master-key-fd "
|
||||
"is mutual exclusive");
|
||||
|
||||
if (keyfile == NULL)
|
||||
asprintf(&keyfile, "%s/m-key", hdb_db_dir(context));
|
||||
if (keyfile == NULL) {
|
||||
aret = asprintf(&keyfile, "%s/m-key", hdb_db_dir(context));
|
||||
if (aret == -1)
|
||||
krb5_errx(context, 1, "out of memory");
|
||||
}
|
||||
|
||||
ret = krb5_string_to_enctype(context, enctype_str, &enctype);
|
||||
if(ret)
|
||||
@@ -132,9 +136,21 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
{
|
||||
char *new, *old;
|
||||
asprintf(&old, "%s.old", keyfile);
|
||||
asprintf(&new, "%s.new", keyfile);
|
||||
char *new = NULL, *old = NULL;
|
||||
int aret;
|
||||
|
||||
aret = asprintf(&old, "%s.old", keyfile);
|
||||
if (aret == -1) {
|
||||
old = NULL;
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
aret = asprintf(&new, "%s.new", keyfile);
|
||||
if (aret == -1) {
|
||||
new = NULL;
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if(unlink(new) < 0 && errno != ENOENT) {
|
||||
ret = errno;
|
||||
goto out;
|
||||
|
@@ -2035,7 +2035,14 @@ krb5_kdc_pk_initialize(krb5_context context,
|
||||
"pkinit_mappings_file",
|
||||
NULL);
|
||||
if (file == NULL) {
|
||||
asprintf(&fn, "%s/pki-mapping", hdb_db_dir(context));
|
||||
int aret;
|
||||
|
||||
aret = asprintf(&fn, "%s/pki-mapping", hdb_db_dir(context));
|
||||
if (aret == -1) {
|
||||
krb5_warnx(context, "PKINIT: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
file = fn;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user