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:
Roland C. Dowdeswell
2012-02-20 19:45:41 +00:00
parent 8ce8cb509a
commit cc47c8fa7b
147 changed files with 1083 additions and 665 deletions

View File

@@ -150,8 +150,8 @@ doit(const char *fn)
static int version_flag;
static int help_flag;
struct getargs args[] = {
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 0, arg_flag, &help_flag, NULL, NULL }
};
int num_args = sizeof(args) / sizeof(args[0]);

View File

@@ -315,10 +315,11 @@ doit (const char *filename)
static int version_flag;
static int help_flag;
struct getargs args[] = {
{ "indent", 0, arg_negative_flag, &indent_flag },
{ "inner", 0, arg_flag, &inner_flag, "try to parse inner structures of OCTET STRING" },
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
{ "indent", 0, arg_negative_flag, &indent_flag, NULL, NULL },
{ "inner", 0, arg_flag, &inner_flag,
"try to parse inner structures of OCTET STRING", NULL },
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 0, arg_flag, &help_flag, NULL, NULL }
};
int num_args = sizeof(args) / sizeof(args[0]);

View File

@@ -178,15 +178,20 @@ static RETSIGTYPE
segv_handler(int sig)
{
int fd;
ssize_t ret;
char msg[] = "SIGSEGV i current test: ";
fd = open("/dev/stdout", O_WRONLY, 0600);
if (fd >= 0) {
write(fd, msg, sizeof(msg));
write(fd, current_test, strlen(current_test));
write(fd, " ", 1);
write(fd, current_state, strlen(current_state));
write(fd, "\n", 1);
ret = write(fd, msg, sizeof(msg));
if (ret != -1)
ret = write(fd, current_test, strlen(current_test));
if (ret != -1)
ret = write(fd, " ", 1);
if (ret != -1)
ret = write(fd, current_state, strlen(current_state));
if (ret != -1)
ret = write(fd, "\n", 1);
close(fd);
}
_exit(1);

View File

@@ -58,16 +58,16 @@ static int
test_integer (void)
{
struct test_case tests[] = {
{NULL, 1, "\x00"},
{NULL, 1, "\x7f"},
{NULL, 2, "\x00\x80"},
{NULL, 2, "\x01\x00"},
{NULL, 1, "\x80"},
{NULL, 2, "\xff\x7f"},
{NULL, 1, "\xff"},
{NULL, 2, "\xff\x01"},
{NULL, 2, "\x00\xff"},
{NULL, 4, "\x7f\xff\xff\xff"}
{NULL, 1, "\x00", NULL},
{NULL, 1, "\x7f", NULL},
{NULL, 2, "\x00\x80", NULL},
{NULL, 2, "\x01\x00", NULL},
{NULL, 1, "\x80", NULL},
{NULL, 2, "\xff\x7f", NULL},
{NULL, 1, "\xff", NULL},
{NULL, 2, "\xff\x01", NULL},
{NULL, 2, "\x00\xff", NULL},
{NULL, 4, "\x7f\xff\xff\xff", NULL}
};
int values[] = {0, 127, 128, 256, -128, -129, -1, -255, 255,
@@ -184,14 +184,14 @@ static int
test_unsigned (void)
{
struct test_case tests[] = {
{NULL, 1, "\x00"},
{NULL, 1, "\x7f"},
{NULL, 2, "\x00\x80"},
{NULL, 2, "\x01\x00"},
{NULL, 2, "\x02\x00"},
{NULL, 3, "\x00\x80\x00"},
{NULL, 5, "\x00\x80\x00\x00\x00"},
{NULL, 4, "\x7f\xff\xff\xff"}
{NULL, 1, "\x00", NULL},
{NULL, 1, "\x7f", NULL},
{NULL, 2, "\x00\x80", NULL},
{NULL, 2, "\x01\x00", NULL},
{NULL, 2, "\x02\x00", NULL},
{NULL, 3, "\x00\x80\x00", NULL},
{NULL, 5, "\x00\x80\x00\x00\x00", NULL},
{NULL, 4, "\x7f\xff\xff\xff", NULL}
};
unsigned int values[] = {0, 127, 128, 256, 512, 32768,
@@ -237,7 +237,7 @@ test_octet_string (void)
heim_octet_string s1 = {8, "\x01\x23\x45\x67\x89\xab\xcd\xef"};
struct test_case tests[] = {
{NULL, 8, "\x01\x23\x45\x67\x89\xab\xcd\xef"}
{NULL, 8, "\x01\x23\x45\x67\x89\xab\xcd\xef", NULL}
};
int ntests = sizeof(tests) / sizeof(*tests);
int ret;
@@ -278,8 +278,8 @@ test_bmp_string (void)
heim_bmp_string s2 = { 2, bmp_d2 };
struct test_case tests[] = {
{NULL, 2, "\x00\x20"},
{NULL, 4, "\x00\x20\x00\x20"}
{NULL, 2, "\x00\x20", NULL},
{NULL, 4, "\x00\x20\x00\x20", NULL}
};
int ntests = sizeof(tests) / sizeof(*tests);
int ret;
@@ -326,8 +326,8 @@ test_universal_string (void)
heim_universal_string s2 = { 2, universal_d2 };
struct test_case tests[] = {
{NULL, 4, "\x00\x00\x00\x20"},
{NULL, 8, "\x00\x00\x00\x20\x00\x00\x00\x20"}
{NULL, 4, "\x00\x00\x00\x20", NULL},
{NULL, 8, "\x00\x00\x00\x20\x00\x00\x00\x20", NULL}
};
int ntests = sizeof(tests) / sizeof(*tests);
int ret;
@@ -370,7 +370,7 @@ test_general_string (void)
char *s1 = "Test User 1";
struct test_case tests[] = {
{NULL, 11, "\x54\x65\x73\x74\x20\x55\x73\x65\x72\x20\x31"}
{NULL, 11, "\x54\x65\x73\x74\x20\x55\x73\x65\x72\x20\x31", NULL}
};
int ret, ntests = sizeof(tests) / sizeof(*tests);
@@ -404,8 +404,8 @@ static int
test_generalized_time (void)
{
struct test_case tests[] = {
{NULL, 15, "19700101000000Z"},
{NULL, 15, "19851106210627Z"}
{NULL, 15, "19700101000000Z", NULL},
{NULL, 15, "19851106210627Z", NULL}
};
time_t values[] = {0, 500159187};
int i, ret;
@@ -446,10 +446,10 @@ static int
test_oid (void)
{
struct test_case tests[] = {
{NULL, 2, "\x29\x01"},
{NULL, 1, "\x29"},
{NULL, 2, "\xff\x01"},
{NULL, 1, "\xff"}
{NULL, 2, "\x29\x01", NULL},
{NULL, 1, "\x29", NULL},
{NULL, 2, "\xff\x01", NULL},
{NULL, 1, "\xff", NULL}
};
heim_oid values[] = {
{ 3, oid_comp1 },
@@ -490,7 +490,7 @@ static int
test_bit_string (void)
{
struct test_case tests[] = {
{NULL, 1, "\x00"}
{NULL, 1, "\x00", NULL}
};
heim_bit_string values[] = {
{ 0, "" }
@@ -528,13 +528,13 @@ static int
test_heim_integer (void)
{
struct test_case tests[] = {
{NULL, 2, "\xfe\x01"},
{NULL, 2, "\xef\x01"},
{NULL, 3, "\xff\x00\xff"},
{NULL, 3, "\xff\x01\x00"},
{NULL, 1, "\x00"},
{NULL, 1, "\x01"},
{NULL, 2, "\x00\x80"}
{NULL, 2, "\xfe\x01", NULL},
{NULL, 2, "\xef\x01", NULL},
{NULL, 3, "\xff\x00\xff", NULL},
{NULL, 3, "\xff\x01\x00", NULL},
{NULL, 1, "\x00", NULL},
{NULL, 1, "\x01", NULL},
{NULL, 2, "\x00\x80", NULL}
};
heim_integer values[] = {
@@ -592,8 +592,8 @@ static int
test_boolean (void)
{
struct test_case tests[] = {
{NULL, 1, "\xff"},
{NULL, 1, "\x00"}
{NULL, 1, "\xff", NULL},
{NULL, 1, "\x00", NULL}
};
int values[] = { 1, 0 };

View File

@@ -98,18 +98,21 @@ test_principal (void)
struct test_case tests[] = {
{ NULL, 29,
"\x30\x1b\xa0\x10\x30\x0e\xa0\x03\x02\x01\x01\xa1\x07\x30\x05\x1b"
"\x03\x6c\x68\x61\xa1\x07\x1b\x05\x53\x55\x2e\x53\x45"
"\x03\x6c\x68\x61\xa1\x07\x1b\x05\x53\x55\x2e\x53\x45",
NULL
},
{ NULL, 35,
"\x30\x21\xa0\x16\x30\x14\xa0\x03\x02\x01\x01\xa1\x0d\x30\x0b\x1b"
"\x03\x6c\x68\x61\x1b\x04\x72\x6f\x6f\x74\xa1\x07\x1b\x05\x53\x55"
"\x2e\x53\x45"
"\x2e\x53\x45",
NULL
},
{ NULL, 54,
"\x30\x34\xa0\x26\x30\x24\xa0\x03\x02\x01\x03\xa1\x1d\x30\x1b\x1b"
"\x04\x68\x6f\x73\x74\x1b\x13\x6e\x75\x74\x63\x72\x61\x63\x6b\x65"
"\x72\x2e\x65\x2e\x6b\x74\x68\x2e\x73\x65\xa1\x0a\x1b\x08\x45\x2e"
"\x4b\x54\x48\x2e\x53\x45"
"\x4b\x54\x48\x2e\x53\x45",
NULL
}
};
@@ -171,7 +174,8 @@ test_authenticator (void)
"\x45\x2e\x4b\x54\x48\x2e\x53\x45\xa2\x10\x30\x0e\xa0"
"\x03\x02\x01\x01\xa1\x07\x30\x05\x1b\x03\x6c\x68\x61"
"\xa4\x03\x02\x01\x0a\xa5\x11\x18\x0f\x31\x39\x37\x30"
"\x30\x31\x30\x31\x30\x30\x30\x31\x33\x39\x5a"
"\x30\x31\x30\x31\x30\x30\x30\x31\x33\x39\x5a",
NULL
},
{ NULL, 67,
"\x62\x41\x30\x3f\xa0\x03\x02\x01\x05\xa1\x07\x1b\x05"
@@ -179,7 +183,8 @@ test_authenticator (void)
"\x01\xa1\x0d\x30\x0b\x1b\x03\x6c\x68\x61\x1b\x04\x72"
"\x6f\x6f\x74\xa4\x04\x02\x02\x01\x24\xa5\x11\x18\x0f"
"\x31\x39\x37\x30\x30\x31\x30\x31\x30\x30\x31\x36\x33"
"\x39\x5a"
"\x39\x5a",
NULL
}
};
@@ -532,7 +537,7 @@ test_time (void)
"time 1" },
{ NULL, 17,
"\x18\x0f\x32\x30\x30\x39\x30\x35\x32\x34\x30\x32\x30\x32\x34\x30"
"\x5a"
"\x5a",
"time 2" }
};
@@ -1185,7 +1190,7 @@ check_fail_largetag(void)
{NULL, 0, "", "empty buffer"},
{NULL, 7, "\x30\x05\xa1\x03\x02\x02\x01",
"one too short" },
{NULL, 7, "\x30\x04\xa1\x03\x02\x02\x01"
{NULL, 7, "\x30\x04\xa1\x03\x02\x02\x01",
"two too short" },
{NULL, 7, "\x30\x03\xa1\x03\x02\x02\x01",
"three too short" },
@@ -1220,7 +1225,7 @@ check_fail_sequence(void)
{NULL, 0, "", "empty buffer"},
{NULL, 24,
"\x30\x16\xa0\x03\x02\x01\x01\xa1\x08\x30\x06\xbf\x7f\x03\x02\x01\x01"
"\x02\x01\x01\xa2\x03\x02\x01\x01"
"\x02\x01\x01\xa2\x03\x02\x01\x01",
"missing one byte from the end, internal length ok"},
{NULL, 25,
"\x30\x18\xa0\x03\x02\x01\x01\xa1\x08\x30\x06\xbf\x7f\x03\x02\x01\x01"

View File

@@ -193,7 +193,7 @@ range_check(const char *name,
"e = ASN1_MAX_CONSTRAINT; %s;\n"
"}\n",
name, length, (long long)r->max, forwstr);
if (r->min - 1 == r->max || r->min < r->max)
if ((r->min - 1 == r->max || r->min < r->max) && r->min > 0)
fprintf (codefile,
"if ((%s)->%s < %lld) {\n"
"e = ASN1_MIN_CONSTRAINT; %s;\n"

View File

@@ -50,7 +50,7 @@ classname(Der_class class)
{
const char *cn[] = { "ASN1_C_UNIV", "ASN1_C_APPL",
"ASN1_C_CONTEXT", "ASN1_C_PRIV" };
if(class < ASN1_C_UNIV || class > ASN1_C_PRIVATE)
if(class > ASN1_C_PRIVATE)
return "???";
return cn[class];
}

View File

@@ -70,16 +70,16 @@ char *option_file;
int version_flag;
int help_flag;
struct getargs args[] = {
{ "template", 0, arg_flag, &template_flag },
{ "encode-rfc1510-bit-string", 0, arg_flag, &rfc1510_bitstring },
{ "decode-dce-ber", 0, arg_flag, &support_ber },
{ "support-ber", 0, arg_flag, &support_ber },
{ "preserve-binary", 0, arg_strings, &preserve },
{ "sequence", 0, arg_strings, &seq },
{ "one-code-file", 0, arg_flag, &one_code_file },
{ "option-file", 0, arg_string, &option_file },
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
{ "template", 0, arg_flag, &template_flag, NULL, NULL },
{ "encode-rfc1510-bit-string", 0, arg_flag, &rfc1510_bitstring, NULL, NULL},
{ "decode-dce-ber", 0, arg_flag, &support_ber, NULL, NULL },
{ "support-ber", 0, arg_flag, &support_ber, NULL, NULL },
{ "preserve-binary", 0, arg_strings, &preserve, NULL, NULL },
{ "sequence", 0, arg_strings, &seq, NULL, NULL },
{ "one-code-file", 0, arg_flag, &one_code_file, NULL, NULL },
{ "option-file", 0, arg_string, &option_file, NULL, NULL },
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 0, arg_flag, &help_flag, NULL, NULL }
};
int num_args = sizeof(args) / sizeof(args[0]);