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:
@@ -965,8 +965,8 @@ build_proxy_prefix(hx509_context context, const Name *issuer, Name *subject)
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
asprintf(&tstr, "ts-%lu", (unsigned long)t);
|
||||
if (tstr == NULL) {
|
||||
ret = asprintf(&tstr, "ts-%lu", (unsigned long)t);
|
||||
if (ret == -1 || tstr == NULL) {
|
||||
hx509_set_error_string(context, 0, ENOMEM,
|
||||
"Failed to copy subject name");
|
||||
return ENOMEM;
|
||||
|
@@ -3425,7 +3425,9 @@ _hx509_cert_to_env(hx509_context context, hx509_cert cert, hx509_env *env)
|
||||
*env = NULL;
|
||||
|
||||
/* version */
|
||||
asprintf(&buf, "%d", _hx509_cert_get_version(_hx509_get_cert(cert)));
|
||||
ret = asprintf(&buf, "%d", _hx509_cert_get_version(_hx509_get_cert(cert)));
|
||||
if (ret == -1)
|
||||
goto out;
|
||||
ret = hx509_env_add(context, &envcert, "version", buf);
|
||||
free(buf);
|
||||
if (ret)
|
||||
|
@@ -209,7 +209,7 @@ unparse_CMSIdentifier(hx509_context context,
|
||||
CMSIdentifier *id,
|
||||
char **str)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
|
||||
*str = NULL;
|
||||
switch (id->element) {
|
||||
@@ -227,8 +227,8 @@ unparse_CMSIdentifier(hx509_context context,
|
||||
free(name);
|
||||
return ret;
|
||||
}
|
||||
asprintf(str, "certificate issued by %s with serial number %s",
|
||||
name, serial);
|
||||
ret = asprintf(str, "certificate issued by %s with serial number %s",
|
||||
name, serial);
|
||||
free(name);
|
||||
free(serial);
|
||||
break;
|
||||
@@ -242,15 +242,19 @@ unparse_CMSIdentifier(hx509_context context,
|
||||
if (len < 0)
|
||||
return ENOMEM;
|
||||
|
||||
asprintf(str, "certificate with id %s", keyid);
|
||||
ret = asprintf(str, "certificate with id %s", keyid);
|
||||
free(keyid);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
asprintf(str, "certificate have unknown CMSidentifier type");
|
||||
ret = asprintf(str, "certificate have unknown CMSidentifier type");
|
||||
break;
|
||||
}
|
||||
if (*str == NULL)
|
||||
/*
|
||||
* In the following if, we check ret and *str which should be returned/set
|
||||
* by asprintf(3) in every branch of the switch statement.
|
||||
*/
|
||||
if (ret == -1 || *str == NULL)
|
||||
return ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -194,13 +194,14 @@ hx509_err(hx509_context context, int exit_code,
|
||||
va_list ap;
|
||||
const char *msg;
|
||||
char *str;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vasprintf(&str, fmt, ap);
|
||||
ret = vasprintf(&str, fmt, ap);
|
||||
va_end(ap);
|
||||
msg = hx509_get_error_string(context, error_code);
|
||||
if (msg == NULL)
|
||||
msg = "no error";
|
||||
|
||||
errx(exit_code, "%s: %s", str, msg);
|
||||
errx(exit_code, "%s: %s", ret != -1 ? str : "ENOMEM", msg);
|
||||
}
|
||||
|
@@ -372,9 +372,9 @@ cms_create_sd(struct cms_create_sd_options *opt, int argc, char **argv)
|
||||
infile = argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
asprintf(&outfile, "%s.%s", infile,
|
||||
opt->pem_flag ? "pem" : "cms-signeddata");
|
||||
if (outfile == NULL)
|
||||
ret = asprintf(&outfile, "%s.%s", infile,
|
||||
opt->pem_flag ? "pem" : "cms-signeddata");
|
||||
if (ret == -1 || outfile == NULL)
|
||||
errx(1, "out of memory");
|
||||
} else
|
||||
outfile = argv[1];
|
||||
|
@@ -752,11 +752,12 @@ _hx509_pi_printf(int (*func)(void *, const char *), void *ctx,
|
||||
{
|
||||
va_list ap;
|
||||
char *str;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vasprintf(&str, fmt, ap);
|
||||
ret = vasprintf(&str, fmt, ap);
|
||||
va_end(ap);
|
||||
if (str == NULL)
|
||||
if (ret == -1 || str == NULL)
|
||||
return;
|
||||
(*func)(ctx, str);
|
||||
free(str);
|
||||
|
@@ -211,7 +211,10 @@ static struct hx509_keyset_ops keyset_dir = {
|
||||
NULL,
|
||||
dir_iter_start,
|
||||
dir_iter,
|
||||
dir_iter_end
|
||||
dir_iter_end,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
|
@@ -87,7 +87,10 @@ struct hx509_keyset_ops keyset_null = {
|
||||
NULL,
|
||||
null_iter_start,
|
||||
null_iter,
|
||||
null_iter_end
|
||||
null_iter_end,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
|
@@ -226,6 +226,7 @@ static const RSA_METHOD p11_rsa_pkcs1_method = {
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -330,8 +331,10 @@ p11_init_slot(hx509_context context,
|
||||
break;
|
||||
}
|
||||
|
||||
asprintf(&slot->name, "%.*s",
|
||||
(int)i, slot_info.slotDescription);
|
||||
ret = asprintf(&slot->name, "%.*s", (int)i,
|
||||
slot_info.slotDescription);
|
||||
if (ret == -1)
|
||||
return ENOMEM;
|
||||
|
||||
if ((slot_info.flags & CKF_TOKEN_PRESENT) == 0)
|
||||
return 0;
|
||||
@@ -422,7 +425,12 @@ p11_get_session(hx509_context context,
|
||||
|
||||
memset(&prompt, 0, sizeof(prompt));
|
||||
|
||||
asprintf(&str, "PIN code for %s: ", slot->name);
|
||||
ret = asprintf(&str, "PIN code for %s: ", slot->name);
|
||||
if (ret == -1 || str == NULL) {
|
||||
if (context)
|
||||
hx509_set_error_string(context, 0, ENOMEM, "out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
prompt.prompt = str;
|
||||
prompt.type = HX509_PROMPT_TYPE_PASSWORD;
|
||||
prompt.reply.data = pin;
|
||||
@@ -717,9 +725,9 @@ collect_cert(hx509_context context,
|
||||
if ((CK_LONG)query[2].ulValueLen != -1) {
|
||||
char *str;
|
||||
|
||||
asprintf(&str, "%.*s",
|
||||
(int)query[2].ulValueLen, (char *)query[2].pValue);
|
||||
if (str) {
|
||||
ret = asprintf(&str, "%.*s",
|
||||
(int)query[2].ulValueLen, (char *)query[2].pValue);
|
||||
if (ret != -1 && str) {
|
||||
hx509_cert_set_friendly_name(cert, str);
|
||||
free(str);
|
||||
}
|
||||
@@ -1176,7 +1184,9 @@ static struct hx509_keyset_ops keyset_pkcs11 = {
|
||||
p11_iter_start,
|
||||
p11_iter,
|
||||
p11_iter_end,
|
||||
p11_printinfo
|
||||
p11_printinfo,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* HAVE_DLOPEN */
|
||||
|
@@ -697,7 +697,10 @@ static struct hx509_keyset_ops keyset_pkcs12 = {
|
||||
NULL,
|
||||
p12_iter_start,
|
||||
p12_iter,
|
||||
p12_iter_end
|
||||
p12_iter_end,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
|
@@ -47,7 +47,10 @@ struct hx509_lock_data {
|
||||
};
|
||||
|
||||
static struct hx509_lock_data empty_lock_data = {
|
||||
{ 0, NULL }
|
||||
{ 0, NULL },
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
hx509_lock _hx509_empty_lock = &empty_lock_data;
|
||||
|
@@ -615,7 +615,11 @@ add_certificate(const char *cert_file,
|
||||
|
||||
if (pin) {
|
||||
char *str;
|
||||
asprintf(&str, "PASS:%s", pin);
|
||||
ret = asprintf(&str, "PASS:%s", pin);
|
||||
if (ret == -1 || !str) {
|
||||
st_logf("failed to allocate memory\n");
|
||||
return CKR_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
hx509_lock_init(context, &lock);
|
||||
hx509_lock_command_string(lock, str);
|
||||
@@ -815,6 +819,7 @@ get_config_file_for_user(void)
|
||||
|
||||
#ifndef _WIN32
|
||||
char *home = NULL;
|
||||
int ret;
|
||||
|
||||
if (!issuid()) {
|
||||
fn = getenv("SOFTPKCS11RC");
|
||||
@@ -828,9 +833,11 @@ get_config_file_for_user(void)
|
||||
home = pw->pw_dir;
|
||||
}
|
||||
if (fn == NULL) {
|
||||
if (home)
|
||||
asprintf(&fn, "%s/.soft-token.rc", home);
|
||||
else
|
||||
if (home) {
|
||||
ret = asprintf(&fn, "%s/.soft-token.rc", home);
|
||||
if (ret == -1)
|
||||
fn = NULL;
|
||||
} else
|
||||
fn = strdup("/etc/soft-token.rc");
|
||||
}
|
||||
#else /* Windows */
|
||||
@@ -1205,8 +1212,13 @@ C_Login(CK_SESSION_HANDLE hSession,
|
||||
VERIFY_SESSION_HANDLE(hSession, NULL);
|
||||
|
||||
if (pPin != NULL_PTR) {
|
||||
asprintf(&pin, "%.*s", (int)ulPinLen, pPin);
|
||||
st_logf("type: %d password: %s\n", (int)userType, pin);
|
||||
int aret;
|
||||
|
||||
aret = asprintf(&pin, "%.*s", (int)ulPinLen, pPin);
|
||||
if (aret != -1 && pin)
|
||||
st_logf("type: %d password: %s\n", (int)userType, pin);
|
||||
else
|
||||
st_logf("memory error: asprintf failed\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user