From 47b26abe77184f9bedc68e36bdad03332cf67570 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 9 May 2000 22:22:25 +0000 Subject: [PATCH] ensure proper range for argument to ctype functions --- CHANGES | 2 + bin/tests/db/t_db.c | 6 +- bin/tests/names/t_names.c | 782 +++++++++++++++---------------- bin/tests/rbt/t_rbt.c | 16 +- lib/dns/config/confparser.y | 4 +- lib/dns/gen.c | 59 ++- lib/dns/rdata.c | 26 +- lib/dns/sec/dst/openssldh_link.c | 6 +- lib/dns/ttl.c | 3 + lib/isc/inet_aton.c | 20 +- lib/isc/lex.c | 4 +- lib/isc/print.c | 20 +- lib/isc/symtab.c | 3 +- lib/lwres/lwconfig.c | 83 ++-- lib/lwres/lwinetaton.c | 20 +- lib/tests/t_api.c | 2 +- 16 files changed, 535 insertions(+), 521 deletions(-) diff --git a/CHANGES b/CHANGES index fdf4f9c820..093f51f857 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 162. [bug] Ensure proper range for arguments to ctype.h functions. + 161. [cleanup] error in yyparse prototype that only HPUX caught. 160. [cleanup] getnet*() are not going to be implemented at this diff --git a/bin/tests/db/t_db.c b/bin/tests/db/t_db.c index 347c790afa..7fc914f954 100644 --- a/bin/tests/db/t_db.c +++ b/bin/tests/db/t_db.c @@ -337,8 +337,10 @@ test_dns_db_zc_x(char *filename, isc_boolean_t cache, ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, tokens); diff --git a/bin/tests/names/t_names.c b/bin/tests/names/t_names.c index 64f489a364..b2b4f5bb9c 100644 --- a/bin/tests/names/t_names.c +++ b/bin/tests/names/t_names.c @@ -427,28 +427,30 @@ t_dns_label_countbits() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; - /* testname, labelpos, bitpos, expected val */ + /* + * testname, labelpos, bitpos, expected val. + */ cnt = bustline(p, Tokens); if (cnt == 3) { result = test_dns_label_countbits(Tokens[0], - atoi(Tokens[1]), - atoi(Tokens[2])); - } - else { + atoi(Tokens[1]), + atoi(Tokens[2])); + } else { t_info("bad datafile format at line %d\n", - line); + line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_label_countbits_data\n"); t_result(result); } @@ -459,8 +461,8 @@ char *a2 = "dns_label_getbit returns the n'th most significant " static int test_dns_label_getbit(char *test_name, int label_pos, int bit_pos, - int expected_bitval) { - + int expected_bitval) +{ dns_label_t label; dns_name_t dns_name; int bitval; @@ -494,7 +496,6 @@ test_dns_label_getbit(char *test_name, int label_pos, int bit_pos, void t_dns_label_getbit() { - int line; int cnt; int result; @@ -511,29 +512,31 @@ t_dns_label_getbit() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 4) { - /* label, bitpos, expected value */ + /* + * label, bitpos, expected value. + */ result = test_dns_label_getbit(Tokens[0], - atoi(Tokens[1]), - atoi(Tokens[2]), - atoi(Tokens[3])); - } - else { + atoi(Tokens[1]), + atoi(Tokens[2]), + atoi(Tokens[3])); + } else { t_info("bad datafile format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_label_getbit_data\n"); t_result(result); } @@ -753,29 +756,32 @@ t_dns_name_isabsolute() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 2) { - /* label, bitpos, expected value */ - result = test_dns_name_isabsolute( - Tokens[0], - atoi(Tokens[1]) == 0 ? - ISC_FALSE : ISC_TRUE); - } - else { + /* + * label, bitpos, expected value. + */ + result = test_dns_name_isabsolute(Tokens[0], + atoi(Tokens[1]) + == 0 ? + ISC_FALSE : + ISC_TRUE); + } else { t_info("bad datafile format at line %d\n", - line); + line); } - (void) free(p); + (void)free(p); t_result(result); } (void) fclose(fp); - } - else { + } else { t_info("Missing datafile dns_name_isabsolute_data\n"); t_result(result); } @@ -785,7 +791,9 @@ char *a8 = "dns_name_hash(name, case_sensitive) returns " "a hash of 'name' which is case_sensitive if case_sensitive " "is true"; -/* a9 merged with a8 */ +/* + * a9 merged with a8. + */ static int test_dns_name_hash(char *test_name1, char *test_name2, @@ -862,8 +870,10 @@ t_dns_name_hash() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); @@ -880,18 +890,16 @@ t_dns_name_hash() { ISC_FALSE : ISC_TRUE, atoi(Tokens[3]) == 0 ? ISC_FALSE : ISC_TRUE); - } - else { + } else { t_info("bad datafile format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_hash_data\n"); t_result(result); } @@ -905,8 +913,9 @@ char *a10 = "dns_name_fullcompare(name1, name2, orderp, nlabelsp, nbitsp) " "and sets nbitsp to the number of bits name1 and name2 " "have in common"; -/* a11 thru a22 merged into a10 */ - +/* + * a11 thru a22 merged into a10. + */ static char * dns_namereln_to_text(dns_namereln_t reln) { @@ -929,8 +938,10 @@ dns_namereln_to_text(dns_namereln_t reln) { } static int -test_dns_name_fullcompare(char *name1, char *name2, dns_namereln_t exp_dns_reln, - int exp_order, int exp_nlabels, int exp_nbits) { +test_dns_name_fullcompare(char *name1, char *name2, + dns_namereln_t exp_dns_reln, + int exp_order, int exp_nlabels, int exp_nbits) +{ int result; int nfails; int order; @@ -946,7 +957,7 @@ test_dns_name_fullcompare(char *name1, char *name2, dns_namereln_t exp_dns_reln, t_info("testing names %s and %s for relation %s\n", name1, name2, - dns_namereln_to_text(exp_dns_reln)); + dns_namereln_to_text(exp_dns_reln)); dns_result = dname_from_tname(name1, &dns_name1); if (dns_result == ISC_R_SUCCESS) { @@ -973,32 +984,32 @@ test_dns_name_fullcompare(char *name1, char *name2, dns_namereln_t exp_dns_reln, t_info("expected ordering %d, got %d\n", exp_order, order); } - if ((exp_nlabels >= 0) && (nlabels != (unsigned int) exp_nlabels)) { + if ((exp_nlabels >= 0) && + (nlabels != (unsigned int) exp_nlabels)) { ++nfails; t_info("expecting %d labels, got %d\n", - exp_nlabels, nlabels); + exp_nlabels, nlabels); } - if ((exp_nbits >= 0) && (nbits != (unsigned int) exp_nbits)) { + if ((exp_nbits >= 0) && + (nbits != (unsigned int) exp_nbits)) { ++nfails; t_info("expecting %d bits, got %d\n", - exp_nbits, nbits); + exp_nbits, nbits); } if (nfails == 0) result = T_PASS; else result = T_FAIL; - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } - return(result); + return (result); } void @@ -1021,8 +1032,10 @@ t_dns_name_fullcompare() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); @@ -1042,7 +1055,8 @@ t_dns_name_fullcompare() { else if (!strcmp(Tokens[2], "commonancestor")) reln = dns_namereln_commonancestor; else { - t_info("bad format at line %d\n", line); + t_info("bad format at line %d\n", + line); continue; } result = test_dns_name_fullcompare( @@ -1052,17 +1066,15 @@ t_dns_name_fullcompare() { atoi(Tokens[3]), atoi(Tokens[4]), atoi(Tokens[5])); - } - else { + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_fullcompare_data\n"); t_result(result); } @@ -1072,11 +1084,12 @@ char *a23 = "dns_name_compare(name1, name2) returns information about " "the relative ordering under the DNSSEC ordering relationship " "of name1 and name2"; -/* a24 thru a29 merged into a23 */ +/* + * a24 thru a29 merged into a23. + */ static int test_dns_name_compare(char *name1, char *name2, int exp_order) { - int result; int order; isc_result_t dns_result; @@ -1085,10 +1098,9 @@ test_dns_name_compare(char *name1, char *name2, int exp_order) { result = T_UNRESOLVED; - t_info("testing %s %s %s\n", - name1, - exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), - name2); + t_info("testing %s %s %s\n", name1, + exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), + name2); dns_result = dname_from_tname(name1, &dns_name1); if (dns_result == ISC_R_SUCCESS) { @@ -1104,28 +1116,24 @@ test_dns_name_compare(char *name1, char *name2, int exp_order) { order = 1; if (order != exp_order) { t_info("expected order of %d, got %d\n", - exp_order, order); + exp_order, order); result = T_FAIL; - } - else + } else result = T_PASS; - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", dns_result_totext(result)); } - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", dns_result_totext(result)); } - return(result); + return (result); } void -t_dns_name_compare() { - +t_dns_name_compare(void) { int line; int cnt; int result; @@ -1142,31 +1150,31 @@ t_dns_name_compare() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 3) { /* - * name1, name2, order + * name1, name2, order. */ result = test_dns_name_compare( Tokens[0], Tokens[1], atoi(Tokens[2])); - } - else { + } else { t_info("bad datafile format at line %d\n", - line); + line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_compare_data\n"); t_result(result); } @@ -1176,11 +1184,12 @@ char *a30 = "dns_name_rdatacompare(name1, name2) returns information about " "the relative ordering of name1 and name2 as if they are part " "of rdata in DNSSEC canonical form"; -/* a31, a32 merged into a30 */ +/* + * a31, a32 merged into a30. + */ static int test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) { - int result; int order; isc_result_t dns_result; @@ -1189,10 +1198,8 @@ test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) { result = T_UNRESOLVED; - t_info("testing %s %s %s\n", - name1, - exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), - name2); + t_info("testing %s %s %s\n", name1, + exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), name2); dns_result = dname_from_tname(name1, &dns_name1); if (dns_result == ISC_R_SUCCESS) { @@ -1208,20 +1215,17 @@ test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) { order = 1; if (order != exp_order) { t_info("expected order of %d, got %d\n", - exp_order, order); + exp_order, order); result = T_FAIL; - } - else + } else result = T_PASS; - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } return(result); @@ -1229,7 +1233,6 @@ test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) { void t_dns_name_rdatacompare() { - int line; int cnt; int result; @@ -1246,31 +1249,31 @@ t_dns_name_rdatacompare() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 3) { /* - * name1, name2, order + * name1, name2, order. */ result = test_dns_name_rdatacompare( Tokens[0], Tokens[1], atoi(Tokens[2])); - } - else { + } else { t_info("bad datafile format at line %d\n", - line); + line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_rdatacompare_data\n"); t_result(result); } @@ -1281,11 +1284,12 @@ char *a33 = "when name1 is a subdomain of name2, " "dns_name_issubdomain(name1, name2) returns true, " "otherwise it returns false."; -/* a34 merged into a33 */ +/* + * a34 merged into a33. + */ static int test_dns_name_issubdomain(char *name1, char *name2, isc_boolean_t exp_rval) { - int result; isc_boolean_t rval; isc_result_t dns_result; @@ -1294,10 +1298,8 @@ test_dns_name_issubdomain(char *name1, char *name2, isc_boolean_t exp_rval) { result = T_UNRESOLVED; - t_info("testing %s %s a subdomain of %s\n", - name1, - exp_rval == 0 ? "is not" : "is", - name2); + t_info("testing %s %s a subdomain of %s\n", name1, + exp_rval == 0 ? "is not" : "is", name2); dns_result = dname_from_tname(name1, &dns_name1); if (dns_result == ISC_R_SUCCESS) { @@ -1307,29 +1309,25 @@ test_dns_name_issubdomain(char *name1, char *name2, isc_boolean_t exp_rval) { if (rval != exp_rval) { t_info("expected return value of %s, got %s\n", - exp_rval == ISC_TRUE ? "true" : "false", - rval == ISC_TRUE ? "true" : "false"); + exp_rval == ISC_TRUE ? "true" : "false", + rval == ISC_TRUE ? "true" : "false"); result = T_FAIL; - } - else + } else result = T_PASS; - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } - return(result); + return (result); } void -t_dns_name_issubdomain() { - +t_dns_name_issubdomain(void) { int line; int cnt; int result; @@ -1346,31 +1344,32 @@ t_dns_name_issubdomain() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 3) { /* - * name1, name2, issubdomain_p + * name1, name2, issubdomain_p. */ result = test_dns_name_issubdomain( Tokens[0], Tokens[1], atoi(Tokens[2]) == 0 ? - ISC_FALSE : ISC_TRUE); - } - else { - t_info("bad datafile format at line %d\n", line); + ISC_FALSE : ISC_TRUE); + } else { + t_info("bad datafile format at line %d\n", + line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_issubdomain_data\n"); t_result(result); } @@ -1381,7 +1380,6 @@ char *a35 = "dns_name_countlabels(name) returns the number " static int test_dns_name_countlabels(char *test_name, unsigned int exp_nlabels) { - int result; unsigned int nlabels; isc_result_t dns_result; @@ -1398,21 +1396,18 @@ test_dns_name_countlabels(char *test_name, unsigned int exp_nlabels) { if (nlabels != exp_nlabels) { t_info("expected %d, got %d\n", exp_nlabels, nlabels); result = T_FAIL; - } - else + } else result = T_PASS; - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); } return(result); } void -t_dns_name_countlabels() { - +t_dns_name_countlabels(void) { int line; int cnt; int result; @@ -1429,29 +1424,28 @@ t_dns_name_countlabels() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 2) { /* - * name, nlabels + * name, nlabels. */ - result = test_dns_name_countlabels( - Tokens[0], - atoi(Tokens[1])); - } - else { + result = test_dns_name_countlabels(Tokens[0], + atoi(Tokens[1])); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_countlabels_data\n"); t_result(result); } @@ -1468,9 +1462,9 @@ char *a36 = "when n is less than the number of labels in name, " */ static int -test_dns_name_getlabel(char *test_name1, int label1_pos, - char *test_name2, int label2_pos) { - +test_dns_name_getlabel(char *test_name1, int label1_pos, char *test_name2, + int label2_pos) +{ int result; int nfails; unsigned int cnt; @@ -1502,7 +1496,7 @@ test_dns_name_getlabel(char *test_name1, int label1_pos, for (cnt = 0; cnt < dns_label1.length; ++cnt) { if (*p++ != *q++) { t_info("labels differ at position %d", - cnt); + cnt); ++nfails; } } @@ -1510,22 +1504,19 @@ test_dns_name_getlabel(char *test_name1, int label1_pos, result = T_PASS; else result = T_FAIL; - } - else { + } else { t_info("dname_from_tname failed, result == %s", - dns_result_totext(result)); + dns_result_totext(result)); } - } - else { + } else { t_info("dname_from_tname failed, result == %s", - dns_result_totext(result)); + dns_result_totext(result)); } - return(result); + return (result); } void -t_dns_name_getlabel() { - +t_dns_name_getlabel(void) { int line; int cnt; int result; @@ -1542,31 +1533,30 @@ t_dns_name_getlabel() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 4) { /* - * name1, name2, nlabels + * name1, name2, nlabels. */ - result = test_dns_name_getlabel( - Tokens[0], - atoi(Tokens[1]), - Tokens[2], - atoi(Tokens[3])); - } - else { + result = test_dns_name_getlabel(Tokens[0], + atoi(Tokens[1]), + Tokens[2], + atoi(Tokens[3])); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_getlabel_data\n"); t_result(result); } @@ -1578,13 +1568,13 @@ char *a37 = "when source contains at least first + n labels, " "labels in source starting with first"; /* - * we adopt a similiar strategy to that used by the dns_name_getlabel test + * We adopt a similiar strategy to that used by the dns_name_getlabel test. */ static int test_dns_name_getlabelsequence(char *test_name1, int label1_start, - char *test_name2, int label2_start, int range) { - + char *test_name2, int label2_start, int range) +{ int result; int nfails; unsigned int cnt; @@ -1610,11 +1600,13 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start, dns_name_init(&dns_targetname1, NULL); dns_name_init(&dns_targetname2, NULL); dns_name_getlabelsequence(&dns_name1, label1_start, - range, &dns_targetname1); + range, &dns_targetname1); dns_name_getlabelsequence(&dns_name2, label2_start, - range, &dns_targetname2); + range, &dns_targetname2); - /* now convert both targets to text for comparison */ + /* + * Now convert both targets to text for comparison. + */ isc_buffer_init(&buffer1, junk1, BUFLEN); isc_buffer_init(&buffer2, junk2, BUFLEN); dns_name_totext(&dns_targetname1, ISC_TRUE, &buffer1); @@ -1626,13 +1618,12 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start, if (*p != *q) { ++nfails; t_info("names differ at %d\n", - cnt); + cnt); break; } ++p; ++q; } - } - else { + } else { ++nfails; t_info("lengths differ\n"); } @@ -1640,20 +1631,18 @@ test_dns_name_getlabelsequence(char *test_name1, int label1_start, result = T_PASS; else result = T_FAIL; - } - else { + } else { t_info("dname_from_tname failed, result == %s", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); } - } - else { + } else { t_info("dname_from_tname failed, result == %s", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); } - return(result); + return (result); } void -t_dns_name_getlabelsequence() { +t_dns_name_getlabelsequence(void) { int line; int cnt; int result; @@ -1670,32 +1659,32 @@ t_dns_name_getlabelsequence() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 5) { /* - * name1, name2, nlabels + * name1, name2, nlabels. */ result = test_dns_name_getlabelsequence( - Tokens[0], - atoi(Tokens[1]), - Tokens[2], - atoi(Tokens[3]), - atoi(Tokens[4])); - } - else { + Tokens[0], + atoi(Tokens[1]), + Tokens[2], + atoi(Tokens[3]), + atoi(Tokens[4])); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_getlabelsequence_data\n"); t_result(result); } @@ -1728,22 +1717,20 @@ test_dns_name_fromregion(char *test_name) { dns_name_init(&dns_name2, NULL); dns_name_fromregion(&dns_name2, ®ion); dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, - &order, &nlabels, &nbits); - if ( dns_namereln == dns_namereln_equal) + &order, &nlabels, &nbits); + if (dns_namereln == dns_namereln_equal) result = T_PASS; else result = T_FAIL; - } - else { + } else { t_info("dname_from_tname failed, result == %s\n", - dns_result_totext(result)); + dns_result_totext(result)); } return(result); } void -t_dns_name_fromregion() { - +t_dns_name_fromregion(void) { int line; int cnt; int result; @@ -1760,27 +1747,27 @@ t_dns_name_fromregion() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 1) { /* - * test_name + * test_name. */ result = test_dns_name_fromregion(Tokens[0]); - } - else { + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_fromregion_data\n"); t_result(result); } @@ -1789,10 +1776,8 @@ t_dns_name_fromregion() { char *a39 = "dns_name_toregion(name, region) converts a DNS name " "from a region representation to a name representation"; - void -t_dns_name_toregion() { - +t_dns_name_toregion(void) { int line; int cnt; int result; @@ -1809,27 +1794,27 @@ t_dns_name_toregion() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 1) { /* - * test_name + * test_name. */ result = test_dns_name_fromregion(Tokens[0]); - } - else { + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_toregion_data\n"); t_result(result); } @@ -1843,9 +1828,9 @@ char *a40 = "dns_name_fromtext(name, source, origin, downcase, target) " "if downcase is true."; static int -test_dns_name_fromtext(char *test_name1, char *test_name2, - char *test_origin, isc_boolean_t downcase) { - +test_dns_name_fromtext(char *test_name1, char *test_name2, char *test_origin, + isc_boolean_t downcase) +{ int result; int order; unsigned int nlabels; @@ -1893,33 +1878,33 @@ test_dns_name_fromtext(char *test_name1, char *test_name2, if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_fromtext(dns_name3) failed, result == %s\n", dns_result_totext(dns_result)); - return(T_FAIL); + return (T_FAIL); } dns_result = dns_name_fromtext(&dns_name1, &txtbuf1, &dns_name3, - downcase, &binbuf1); + downcase, &binbuf1); if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_fromtext(dns_name1) failed, result == %s\n", - dns_result_totext(dns_result)); - return(T_FAIL); + dns_result_totext(dns_result)); + return (T_FAIL); } dns_result = dns_name_fromtext(&dns_name2, &txtbuf2, NULL, ISC_FALSE, &binbuf2); if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_fromtext(dns_name2) failed, result == %s\n", - dns_result_totext(dns_result)); - return(T_FAIL); + dns_result_totext(dns_result)); + return (T_FAIL); } dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, &order, - &nlabels, &nbits); + &nlabels, &nbits); if (dns_namereln == dns_namereln_equal) result = T_PASS; else { t_info("dns_name_fullcompare returned %s\n", - dns_namereln_to_text(dns_namereln)); + dns_namereln_to_text(dns_namereln)); result = T_FAIL; } @@ -1927,8 +1912,7 @@ test_dns_name_fromtext(char *test_name1, char *test_name2, } void -t_dns_name_fromtext() { - +t_dns_name_fromtext(void) { int line; int cnt; int result; @@ -1945,31 +1929,34 @@ t_dns_name_fromtext() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 4) { /* - * test_name1, test_name2, test_origin - * downcase + * test_name1, test_name2, test_origin, + * downcase. */ result = test_dns_name_fromtext(Tokens[0], - Tokens[1], Tokens[2], - atoi(Tokens[3]) == 0 ? - ISC_FALSE : ISC_TRUE); - } - else { + Tokens[1], + Tokens[2], + atoi(Tokens[3]) + == 0 ? + ISC_FALSE : + ISC_TRUE); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_fromtext\n"); t_result(result); } @@ -1982,7 +1969,6 @@ char *a41 = "dns_name_totext(name, omit_final_dot, target) converts " static int test_dns_name_totext(char *test_name, isc_boolean_t omit_final) { - int result; int len; int order; @@ -2010,52 +1996,57 @@ test_dns_name_totext(char *test_name, isc_boolean_t omit_final) { dns_name_init(&dns_name1, NULL); isc_buffer_init(&buf2, junk2, BUFLEN); - /* out of the data file to dns_name1 */ + /* + * Out of the data file to dns_name1. + */ dns_result = dns_name_fromtext(&dns_name1, &buf1, NULL, ISC_FALSE, - &buf2); + &buf2); if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_fromtext failed, result == %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); + dns_result_totext(dns_result)); + return (T_UNRESOLVED); } - /* from dns_name1 into a text buffer */ + /* + * From dns_name1 into a text buffer. + */ isc_buffer_invalidate(&buf1); isc_buffer_init(&buf1, junk1, BUFLEN); dns_result = dns_name_totext(&dns_name1, omit_final, &buf1); if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_totext failed, result == %s\n", - dns_result_totext(dns_result)); - return(T_FAIL); + dns_result_totext(dns_result)); + return (T_FAIL); } - /* from the text buffer into dns_name2 */ + /* + * From the text buffer into dns_name2. + */ dns_name_init(&dns_name2, NULL); isc_buffer_init(&buf3, junk3, BUFLEN); - dns_result = dns_name_fromtext(&dns_name2, &buf1, - NULL, ISC_FALSE, &buf3); + dns_result = dns_name_fromtext(&dns_name2, &buf1, NULL, ISC_FALSE, + &buf3); if (dns_result != ISC_R_SUCCESS) { t_info("dns_name_fromtext failed, result == %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); + dns_result_totext(dns_result)); + return (T_UNRESOLVED); } dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, - &order, &nlabels, &nbits); + &order, &nlabels, &nbits); if (dns_namereln == dns_namereln_equal) result = T_PASS; else { t_info("dns_name_fullcompare returned %s\n", - dns_namereln_to_text(dns_namereln)); + dns_namereln_to_text(dns_namereln)); result = T_FAIL; } - return(result); + return (result); } void -t_dns_name_totext() { - +t_dns_name_totext(void) { int line; int cnt; int result; @@ -2072,29 +2063,30 @@ t_dns_name_totext() { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); if (cnt == 2) { /* - * test_name, omit_final + * test_name, omit_final. */ - result = test_dns_name_totext( Tokens[0], - atoi(Tokens[1]) == 0 ? - ISC_FALSE : ISC_TRUE); - } - else { + result = test_dns_name_totext(Tokens[0], + atoi(Tokens[1]) == 0 ? + ISC_FALSE : + ISC_TRUE); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile dns_name_totext\n"); t_result(result); } @@ -2132,14 +2124,10 @@ char *a50 = "when there is not enough space in target, " "returns ISC_R_NOSPACE"; static int -test_dns_name_fromwire( char *datafile_name, - int testname_offset, - int downcase, - int dc_method, - char *exp_name, - isc_result_t exp_result, - size_t buflen) { - +test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase, + int dc_method, char *exp_name, isc_result_t exp_result, + size_t buflen) +{ int result; int order; unsigned int nlabels; @@ -2168,39 +2156,34 @@ test_dns_name_fromwire( char *datafile_name, dns_decompress_init(&dctx, -1, ISC_TRUE); dns_decompress_setmethods(&dctx, dc_method); dns_result = dns_name_fromwire(&dns_name1, &iscbuf1, - &dctx, downcase ? ISC_TRUE : ISC_FALSE, &iscbuf2); + &dctx, downcase ? ISC_TRUE : ISC_FALSE, + &iscbuf2); if ((dns_result == exp_result) && (exp_result == ISC_R_SUCCESS)) { dns_result = dname_from_tname(exp_name, &dns_name2); if (dns_result == ISC_R_SUCCESS) { - dns_namereln = dns_name_fullcompare( - &dns_name1, - &dns_name2, - &order, - &nlabels, - &nbits); + dns_namereln = dns_name_fullcompare(&dns_name1, + &dns_name2, + &order, &nlabels, + &nbits); if (dns_namereln != dns_namereln_equal) { t_info("dns_name_fullcompare returned %s\n", - dns_namereln_to_text(dns_namereln)); + dns_namereln_to_text(dns_namereln)); result = T_FAIL; - } - else { + } else { result = T_PASS; } - } - else { + } else { t_info("dns_name_fromtext %s failed, result = %s\n", - exp_name, dns_result_totext(dns_result)); + exp_name, dns_result_totext(dns_result)); result = T_UNRESOLVED; } - } - else if (dns_result == exp_result) { + } else if (dns_result == exp_result) { result = T_PASS; - } - else { + } else { t_info("dns_name_fromwire returned %s\n", - dns_result_totext(dns_result)); + dns_result_totext(dns_result)); result = T_FAIL; } @@ -2209,7 +2192,6 @@ test_dns_name_fromwire( char *datafile_name, static void t_dns_name_fromwire_x(char *testfile, size_t buflen) { - int line; int cnt; int result; @@ -2227,8 +2209,10 @@ t_dns_name_fromwire_x(char *testfile, size_t buflen) { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); @@ -2236,7 +2220,7 @@ t_dns_name_fromwire_x(char *testfile, size_t buflen) { /* * datafile_name, testname_offset, * downcase, dc_method, - * exp_name, exp_result + * exp_name, exp_result. */ tok = Tokens[5]; @@ -2260,40 +2244,36 @@ t_dns_name_fromwire_x(char *testfile, size_t buflen) { dc_method = DNS_COMPRESS_NONE; if (! strcmp(tok, "DNS_COMPRESS_GLOBAL14")) dc_method = DNS_COMPRESS_GLOBAL14; - else if (! strcmp(tok, "DNS_COMPRESS_GLOBAL16")) + else if (! strcmp(tok,"DNS_COMPRESS_GLOBAL16")) dc_method = DNS_COMPRESS_GLOBAL16; else if (! strcmp(tok, "DNS_COMPRESS_GLOBAL")) dc_method = DNS_COMPRESS_GLOBAL; else if (! strcmp(tok, "DNS_COMPRESS_ALL")) dc_method = DNS_COMPRESS_ALL; - result = test_dns_name_fromwire( - Tokens[0], - atoi(Tokens[1]), - atoi(Tokens[2]), - dc_method, - Tokens[4], - exp_result, - buflen); - } - else { + result = test_dns_name_fromwire(Tokens[0], + atoi(Tokens[1]), + atoi(Tokens[2]), + dc_method, + Tokens[4], + exp_result, + buflen); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile %s\n", testfile); t_result(result); } } void -t_dns_name_fromwire() { - +t_dns_name_fromwire(void) { t_assert("dns_name_fromwire", 1, T_REQUIRED, a42); t_dns_name_fromwire_x("dns_name_fromwire_1_data", BUFLEN); @@ -2326,7 +2306,6 @@ t_dns_name_fromwire() { t_assert("dns_name_fromwire", 9, T_REQUIRED, a50); t_dns_name_fromwire_x("dns_name_fromwire_9_data", 2); - } @@ -2339,13 +2318,9 @@ char *a52 = "when not enough space exists in target, " "dns_name_towire(name, cctx, target) returns ISC_R_NOSPACE"; static int -test_dns_name_towire( char *testname, - int dc_method, - char *exp_data, - int exp_data_len, - isc_result_t exp_result, - size_t buflen) { - +test_dns_name_towire(char *testname, int dc_method, char *exp_data, + int exp_data_len, isc_result_t exp_result, size_t buflen) +{ int result; int val; int len; @@ -2384,35 +2359,31 @@ test_dns_name_towire( char *testname, dns_result = dns_name_towire(&dns_name, &cctx, &iscbuf3); if (dns_result == exp_result) { if (exp_result == ISC_R_SUCCESS) { - /* compare results with expected data */ - val = chkdata( buf3, - iscbuf3.used, - exp_data, - exp_data_len); + /* + * Compare results with expected data. + */ + val = chkdata(buf3, iscbuf3.used, exp_data, + exp_data_len); if (val == 0) result = T_PASS; else result = T_FAIL; - } - else + } else result = T_PASS; - } - else { + } else { t_info("dns_name_towire unexpectedly returned %s\n", dns_result_totext(dns_result)); result = T_FAIL; } - } - else { + } else { t_info("dns_name_fromtext %s failed, result = %s\n", testname, dns_result_totext(dns_result)); } - return(result); + return (result); } static void t_dns_name_towire_x(char *testfile, size_t buflen) { - int line; int cnt; int result; @@ -2429,8 +2400,10 @@ t_dns_name_towire_x(char *testfile, size_t buflen) { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = bustline(p, Tokens); @@ -2438,48 +2411,45 @@ t_dns_name_towire_x(char *testfile, size_t buflen) { /* * testname, dc_method, * exp_data, exp_data_len, - * exp_result + * exp_result. */ dc_method = t_dc_method_fromtext(Tokens[3]); exp_result = t_dns_result_fromtext(Tokens[4]); - result = test_dns_name_towire( - Tokens[0], - dc_method, - Tokens[2], - atoi(Tokens[3]), - exp_result, - buflen); - } - else { + result = test_dns_name_towire(Tokens[0], + dc_method, + Tokens[2], + atoi(Tokens[3]), + exp_result, + buflen); + } else { t_info("bad format at line %d\n", line); } - (void) free(p); + (void)free(p); t_result(result); } - (void) fclose(fp); - } - else { + (void)fclose(fp); + } else { t_info("Missing datafile %s\n", testfile); t_result(result); } } void -t_dns_name_towire() { +t_dns_name_towire(void) { t_dns_name_towire_1(); t_dns_name_towire_2(); } void -t_dns_name_towire_1() { +t_dns_name_towire_1(void) { t_assert("dns_name_towire", 1, T_REQUIRED, a51); t_dns_name_towire_x("dns_name_towire_1_data", BUFLEN); } void -t_dns_name_towire_2() { +t_dns_name_towire_2(void) { t_assert("dns_name_towire", 2, T_REQUIRED, a52); t_dns_name_towire_x("dns_name_towire_2_data", 2); } @@ -2490,7 +2460,7 @@ char *a53 = "dns_name_concatenate(prefix, suffix, name, target) " "and returns ISC_R_SUCCESS"; void -t_dns_name_concatenate() { +t_dns_name_concatenate(void) { t_assert("dns_name_concatenate", 1, T_REQUIRED, a53); t_result(T_UNTESTED); } diff --git a/bin/tests/rbt/t_rbt.c b/bin/tests/rbt/t_rbt.c index 60079a4c50..6cded78f82 100644 --- a/bin/tests/rbt/t_rbt.c +++ b/bin/tests/rbt/t_rbt.c @@ -435,7 +435,7 @@ test_dns_rbt_x(char *filename) { /* * Skip comment lines. */ - if ((isspace((int)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; /* @@ -919,8 +919,10 @@ test_dns_rbtnodechain_init(char *filename) { ++line; - /* skip comment lines */ - if ((isspace((int)*p)) || (*p == '#')) + /* + * Skip comment lines. + */ + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, Tokens); @@ -1082,7 +1084,7 @@ test_dns_rbtnodechain_first(char *filename) { /* * Skip comment lines. */ - if ((isspace((int)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, Tokens); @@ -1247,7 +1249,7 @@ test_dns_rbtnodechain_last(char *filename) { /* * Skip comment lines. */ - if ((isspace((int)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, Tokens); @@ -1428,7 +1430,7 @@ test_dns_rbtnodechain_next(char *filename) { /* * Skip comment lines. */ - if ((isspace((int)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, Tokens); @@ -1607,7 +1609,7 @@ test_dns_rbtnodechain_prev(char *filename) { /* * Skip comment lines. */ - if ((isspace((int)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, Tokens); diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y index 2209fe59ab..d47795818f 100644 --- a/lib/dns/config/confparser.y +++ b/lib/dns/config/confparser.y @@ -16,7 +16,7 @@ * SOFTWARE. */ -/* $Id: confparser.y,v 1.76 2000/05/09 16:49:50 brister Exp $ */ +/* $Id: confparser.y,v 1.77 2000/05/09 22:22:15 tale Exp $ */ #include @@ -5496,7 +5496,7 @@ unit_to_uint32(char *in, isc_uint32_t *out) { for (; (c = *in) != '\0'; in++) { if (units_done) return (ISC_FALSE); - if (isdigit(c)) { + if (isdigit((unsigned char)c)) { result *= 10; result += (c - '0'); } else { diff --git a/lib/dns/gen.c b/lib/dns/gen.c index 415f1782e1..c19f7f11fa 100644 --- a/lib/dns/gen.c +++ b/lib/dns/gen.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: gen.c,v 1.45 2000/05/08 14:34:36 tale Exp $ */ +/* $Id: gen.c,v 1.46 2000/05/09 22:22:11 tale Exp $ */ #include @@ -34,31 +34,38 @@ #include "gen-unix.h" #endif -#define FROMTEXTDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target" +#define FROMTEXTDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, " \ + "isc_lex_t *lexer, dns_name_t *origin, " \ + "isc_boolean_t downcase, isc_buffer_t *target" #define FROMTEXTARGS "rdclass, type, lexer, origin, downcase, target" #define FROMTEXTCLASS "rdclass" #define FROMTEXTTYPE "type" #define FROMTEXTDEF "use_default = ISC_TRUE" -#define TOTEXTDECL "dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target" +#define TOTEXTDECL "dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, " \ + "isc_buffer_t *target" #define TOTEXTARGS "rdata, tctx, target" #define TOTEXTCLASS "rdata->rdclass" #define TOTEXTTYPE "rdata->type" #define TOTEXTDEF "use_default = ISC_TRUE" -#define FROMWIREDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target" +#define FROMWIREDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, " \ + "isc_buffer_t *source, dns_decompress_t *dctx, " \ + "isc_boolean_t downcase, isc_buffer_t *target" #define FROMWIREARGS "rdclass, type, source, dctx, downcase, target" #define FROMWIRECLASS "rdclass" #define FROMWIRETYPE "type" #define FROMWIREDEF "use_default = ISC_TRUE" -#define TOWIREDECL "dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target" +#define TOWIREDECL "dns_rdata_t *rdata, dns_compress_t *cctx, " \ + "isc_buffer_t *target" #define TOWIREARGS "rdata, cctx, target" #define TOWIRECLASS "rdata->rdclass" #define TOWIRETYPE "rdata->type" #define TOWIREDEF "use_default = ISC_TRUE" -#define FROMSTRUCTDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source, isc_buffer_t *target" +#define FROMSTRUCTDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, " \ + "void *source, isc_buffer_t *target" #define FROMSTRUCTARGS "rdclass, type, source, target" #define FROMSTRUCTCLASS "rdclass" #define FROMSTRUCTTYPE "type" @@ -104,14 +111,14 @@ char copyright[] = " * purpose with or without fee is hereby granted, provided that the above\n" " * copyright notice and this permission notice appear in all copies.\n" " *\n" -" * THE SOFTWARE IS PROVIDED \"AS IS\" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS\n" -" * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES\n" -" * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE\n" -" * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\n" -" * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR\n" -" * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\n" -" * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\n" -" * SOFTWARE.\n" +" * THE SOFTWARE IS PROVIDED \"AS IS\" AND INTERNET SOFTWARE CONSORTIUM\n" +" * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL\n" +" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL\n" +" * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,\n" +" * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING\n" +" * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n" +" * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION\n" +" * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n" " */\n" "\n" "/***************\n" @@ -372,8 +379,9 @@ add(int rdclass, char *classname, int type, char *typename, char *dirname) { else types = newtt; - /* do a class switch for this type */ - + /* + * Do a class switch for this type. + */ if (rdclass == 0) return; @@ -585,8 +593,10 @@ main(int argc, char **argv) { #define PRINT_COMMA(x) (x == 255 ? "" : ",") -#define METANOTQUESTION "DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_NOTQUESTION" -#define METAQUESTIONONLY "DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY" +#define METANOTQUESTION "DNS_RDATATYPEATTR_META | " \ + "DNS_RDATATYPEATTR_NOTQUESTION" +#define METAQUESTIONONLY "DNS_RDATATYPEATTR_META | " \ + "DNS_RDATATYPEATTR_QUESTIONONLY" #define RESERVED "DNS_RDATATYPEATTR_RESERVED" /* @@ -649,14 +659,16 @@ main(int argc, char **argv) { printf("#define RDATATYPE_COMPARE(_s, _d, _tn, _tp) \\\n"); printf("\tdo { \\\n"); printf("\t\tif (strcasecmp(_s,(_tn)) == 0) { \\\n"); - printf("\t\t\tif ((typeattr[_d].flags & DNS_RDATATYPEATTR_RESERVED) != 0) \\\n"); + printf("\t\t\tif ((typeattr[_d].flags & " + "DNS_RDATATYPEATTR_RESERVED) != 0) \\\n"); printf("\t\t\t\treturn (ISC_R_NOTIMPLEMENTED); \\\n"); printf("\t\t\t*(_tp) = _d; \\\n"); printf("\t\t\treturn (ISC_R_SUCCESS); \\\n"); printf("\t\t} \\\n"); printf("\t} while (0)\n\n"); - printf("#define RDATATYPE_FROMTEXT_SW(_hash,_typename,_typep) \\\n"); + printf("#define RDATATYPE_FROMTEXT_SW(_hash,_typename,_typep) " + "\\\n"); printf("\tswitch (_hash) { \\\n"); for (i = 0 ; i <= 255 ; i++) { ttn = &typenames[i]; @@ -679,7 +691,9 @@ main(int argc, char **argv) { if (ttn2->sorted != 0) continue; if (hash == HASH(ttn2->typename)) { - printf("\t\t\tRDATATYPE_COMPARE(\"%s\", %u, _typename, _typep); \\\n", + printf("\t\t\tRDATATYPE_COMPARE" + "(\"%s\", %u, " + "_typename, _typep); \\\n", ttn2->typename, j); ttn2->sorted = 1; } @@ -713,7 +727,8 @@ main(int argc, char **argv) { lasttype = 0; for (tt = types; tt != NULL ; tt = tt->next) if (tt->type != lasttype) - fprintf(stdout, "\t dns_rdatatype_%s = %d,%s\n", + fprintf(stdout, + "\t dns_rdatatype_%s = %d,%s\n", funname(tt->typename, buf1), lasttype = tt->type, tt->next != NULL ? " \\" : ""); diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 224f56b7fc..c71613257c 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: rdata.c,v 1.87 2000/05/09 12:07:32 tale Exp $ */ +/* $Id: rdata.c,v 1.88 2000/05/09 22:22:12 tale Exp $ */ #include @@ -812,8 +812,8 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) { if (n == 0) return (DNS_R_UNKNOWN); - a = tolower(source->base[0]); - b = tolower(source->base[n - 1]); + a = tolower((unsigned char)source->base[0]); + b = tolower((unsigned char)source->base[n - 1]); hash = ((a + n) * b) % 256; @@ -1308,10 +1308,14 @@ compare_region(isc_region_t *r1, isc_region_t *r2) { static int hexvalue(char value) { char *s; - if (!isascii(value & 0xff)) + unsigned char c; + + c = (unsigned char)value; + + if (!isascii(c)) return (-1); - if (isupper(value & 0xff)) - value = tolower(value); + if (isupper(c)) + c = tolower(c); if ((s = strchr(hexdigits, value)) == NULL) return (-1); return (s - hexdigits); @@ -1320,7 +1324,12 @@ hexvalue(char value) { static int decvalue(char value) { char *s; - if (!isascii(value&0xff)) + + /* + * isascii() is valid for full range of int values, no need to + * mask or cast. + */ + if (!isascii(value)) return (-1); if ((s = strchr(decdigits, value)) == NULL) return (-1); @@ -1328,7 +1337,8 @@ decvalue(char value) { } static const char atob_digits[86] = -"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"; + "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \ + "abcdefghijklmnopqrstu"; /* * Subroutines to convert between 8 bit binary bytes and printable ASCII. * Computes the number of bytes, and three kinds of simple checksums. diff --git a/lib/dns/sec/dst/openssldh_link.c b/lib/dns/sec/dst/openssldh_link.c index 084812af13..37426580cf 100644 --- a/lib/dns/sec/dst/openssldh_link.c +++ b/lib/dns/sec/dst/openssldh_link.c @@ -19,7 +19,7 @@ /* * Principal Author: Brian Wellington - * $Id: openssldh_link.c,v 1.12 2000/05/08 14:37:09 tale Exp $ + * $Id: openssldh_link.c,v 1.13 2000/05/09 22:22:16 tale Exp $ */ #if defined(OPENSSL) @@ -687,11 +687,11 @@ BN_fromhex(BIGNUM *b, const char *str) { char *s; unsigned int high, low; - s = strchr(hexdigits, tolower(str[i])); + s = strchr(hexdigits, tolower((unsigned char)str[i])); RUNTIME_CHECK(s != NULL); high = s - hexdigits; - s = strchr(hexdigits, tolower(str[i + 1])); + s = strchr(hexdigits, tolower((unsigned char)str[i + 1])); RUNTIME_CHECK(s != NULL); low = s - hexdigits; diff --git a/lib/dns/ttl.c b/lib/dns/ttl.c index e976f3f574..11186c12ca 100644 --- a/lib/dns/ttl.c +++ b/lib/dns/ttl.c @@ -109,6 +109,9 @@ dns_ttl_totext(isc_uint32_t src, isc_boolean_t verbose, isc_buffer_t *target) { /* * The unit letter is the last character in the * used region of the buffer. + * + * toupper() does not need its argument to be masked of cast + * here because region.base is type unsigned char *. */ isc_buffer_usedregion(target, ®ion); region.base[region.length - 1] = diff --git a/lib/isc/inet_aton.c b/lib/isc/inet_aton.c index 26c71201fc..0c0cee04e4 100644 --- a/lib/isc/inet_aton.c +++ b/lib/isc/inet_aton.c @@ -70,7 +70,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; -static char rcsid[] = "$Id: inet_aton.c,v 1.8 1999/10/29 04:25:11 marka Exp $"; +static char rcsid[] = "$Id: inet_aton.c,v 1.9 2000/05/09 22:22:18 tale Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -88,8 +88,7 @@ static char rcsid[] = "$Id: inet_aton.c,v 1.8 1999/10/29 04:25:11 marka Exp $"; * cannot distinguish between failure and a local broadcast address. */ int -isc_net_aton(const char *cp, struct in_addr *addr) -{ +isc_net_aton(const char *cp, struct in_addr *addr) { unsigned long val; int base, n; char c; @@ -117,16 +116,21 @@ isc_net_aton(const char *cp, struct in_addr *addr) } } for (;;) { - if (isascii(c & 0xff) && isdigit(c & 0xff)) { + /* + * isascii() is valid for all integer values, and + * when it is true, c is known to be in scope + * for isdigit(). No cast necessary. Similar + * comment applies for later ctype uses. + */ + if (isascii(c) && isdigit(c)) { if (base == 8 && (c == '8' || c == '9')) return (0); val = (val * base) + (c - '0'); c = *++cp; digit = 1; - } else if (base == 16 && isascii(c & 0xff) && - isxdigit(c & 0xff)) { + } else if (base == 16 && isascii(c) && isxdigit(c)) { val = (val << 4) | - (c + 10 - (islower(c & 0xff) ? 'a' : 'A')); + (c + 10 - (islower(c) ? 'a' : 'A')); c = *++cp; digit = 1; } else @@ -149,7 +153,7 @@ isc_net_aton(const char *cp, struct in_addr *addr) /* * Check for trailing characters. */ - if (c != '\0' && (!isascii(c & 0xff) || !isspace(c & 0xff))) + if (c != '\0' && (!isascii(c) || !isspace(c))) return (0); /* * Did we get a valid digit? diff --git a/lib/isc/lex.c b/lib/isc/lex.c index b002521058..2f1b3ee34d 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -489,7 +489,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { tokenp->type = isc_tokentype_special; tokenp->value.as_char = c; done = ISC_TRUE; - } else if (isdigit(c) && + } else if (isdigit((unsigned char)c) && (options & ISC_LEXOPT_NUMBER) != 0) { lex->last_was_eol = ISC_FALSE; state = lexstate_number; @@ -508,7 +508,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { lex->last_was_eol = ISC_TRUE; break; case lexstate_number: - if (!isdigit(c)) { + if (c == EOF || !isdigit((unsigned char)c)) { if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == EOF || lex->specials[c]) { diff --git a/lib/isc/print.c b/lib/isc/print.c index 755df480ca..51611035e5 100644 --- a/lib/isc/print.c +++ b/lib/isc/print.c @@ -97,7 +97,9 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) { } format++; - /* reset flags */ + /* + * Reset flags. + */ dot = neg = space = plus = left = zero = alt = h = l = q = 0; width = precision = 0; head = ""; @@ -127,24 +129,28 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) { break; } while (1); - /* width */ + /* + * Width. + */ if (*format == '*') { width = va_arg(ap, int); format++; - } else if (isdigit(*format)) { + } else if (isdigit((unsigned char)*format)) { char *e; width = strtoul(format, &e, 10); format = e; } - /* precision */ + /* + * Precision. + */ if (*format == '.') { format++; dot = 1; if (*format == '*') { precision = va_arg(ap, int); format++; - } else if (isdigit(*format)) { + } else if (isdigit((unsigned char)*format)) { char *e; precision = strtoul(format, &e, 10); format = e; @@ -346,7 +352,9 @@ isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) { REQUIRE(cp != NULL); if (precision != 0) { - /* cp need not be NULL terminated */ + /* + * cp need not be NULL terminated. + */ char *tp; unsigned long n; diff --git a/lib/isc/symtab.c b/lib/isc/symtab.c index 6897a3bf1d..00b0eafbc2 100644 --- a/lib/isc/symtab.c +++ b/lib/isc/symtab.c @@ -138,8 +138,7 @@ hash(const char *key, isc_boolean_t case_sensitive) { } else { for (s = key; *s != '\0'; s++) { c = *s; - if (isascii(c) && isupper(c)) - c = tolower(c); + c = tolower((unsigned char)c); h = ( h << 4 ) + c; if ((g = ( h & 0xf0000000 )) != 0) { h = h ^ (g >> 24); diff --git a/lib/lwres/lwconfig.c b/lib/lwres/lwconfig.c index 2b5cd1824a..4f23de4a2f 100644 --- a/lib/lwres/lwconfig.c +++ b/lib/lwres/lwconfig.c @@ -96,8 +96,7 @@ lwres_create_addr(const char *buff, lwres_addr_t *addr); * that caused the reading to stop. */ static int -getword(FILE *fp, char *buffer, size_t size) -{ +getword(FILE *fp, char *buffer, size_t size) { int ch; char *p = buffer; @@ -107,7 +106,7 @@ getword(FILE *fp, char *buffer, size_t size) *p = '\0'; ch = fgetc(fp); - while (ch != '\n' && isspace(ch)) + while (ch != '\n' && ch != EOF && isspace((unsigned char)ch)) ch = fgetc(fp); if (ch == EOF) @@ -116,10 +115,10 @@ getword(FILE *fp, char *buffer, size_t size) do { *p = '\0'; - if (ch == EOF || isspace(ch)) + if (ch == EOF || isspace((unsigned char)ch)) break; else if ((size_t) (p - buffer) == size - 1) - return (EOF); /* not enough space */ + return (EOF); /* Not enough space. */ *p++ = (char)ch; ch = fgetc(fp); @@ -129,8 +128,7 @@ getword(FILE *fp, char *buffer, size_t size) } static void -lwres_resetaddr(lwres_addr_t *addr) -{ +lwres_resetaddr(lwres_addr_t *addr) { REQUIRE(addr != NULL); memset(addr->address, 0, LWRES_ADDR_MAXLEN); @@ -139,8 +137,7 @@ lwres_resetaddr(lwres_addr_t *addr) } static char * -lwres_strdup(lwres_context_t *ctx, const char *str) -{ +lwres_strdup(lwres_context_t *ctx, const char *str) { char *p; REQUIRE(str != NULL); @@ -154,8 +151,7 @@ lwres_strdup(lwres_context_t *ctx, const char *str) } void -lwres_conf_init(lwres_context_t *ctx) -{ +lwres_conf_init(lwres_context_t *ctx) { int i; lwres_conf_t *confdata; @@ -183,8 +179,7 @@ lwres_conf_init(lwres_context_t *ctx) } void -lwres_conf_clear(lwres_context_t *ctx) -{ +lwres_conf_clear(lwres_context_t *ctx) { int i; lwres_conf_t *confdata; @@ -223,8 +218,7 @@ lwres_conf_clear(lwres_context_t *ctx) } static lwres_result_t -lwres_conf_parsenameserver(lwres_context_t *ctx, FILE *fp) -{ +lwres_conf_parsenameserver(lwres_context_t *ctx, FILE *fp) { char word[LWRES_CONFMAXLINELEN]; int res; lwres_conf_t *confdata; @@ -236,9 +230,9 @@ lwres_conf_parsenameserver(lwres_context_t *ctx, FILE *fp) res = getword(fp, word, sizeof(word)); if (strlen(word) == 0) - return (LWRES_R_FAILURE); /* nothing on line */ + return (LWRES_R_FAILURE); /* Nothing on line. */ else if (res != EOF && res != '\n') - return (LWRES_R_FAILURE); /* extra junk on line */ + return (LWRES_R_FAILURE); /* Extra junk on line. */ res = lwres_create_addr(word, &confdata->nameservers[confdata->nsnext++]); @@ -249,8 +243,7 @@ lwres_conf_parsenameserver(lwres_context_t *ctx, FILE *fp) } static lwres_result_t -lwres_conf_parsedomain(lwres_context_t *ctx, FILE *fp) -{ +lwres_conf_parsedomain(lwres_context_t *ctx, FILE *fp) { char word[LWRES_CONFMAXLINELEN]; int res, i; lwres_conf_t *confdata; @@ -259,15 +252,17 @@ lwres_conf_parsedomain(lwres_context_t *ctx, FILE *fp) res = getword(fp, word, sizeof(word)); if (strlen(word) == 0) - return (LWRES_R_FAILURE); /* nothing else on line */ + return (LWRES_R_FAILURE); /* Nothing else on line. */ else if (res != EOF && res != '\n') - return (LWRES_R_FAILURE); /* extra junk on line */ + return (LWRES_R_FAILURE); /* Extra junk on line. */ if (confdata->domainname != NULL) CTXFREE(confdata->domainname, strlen(confdata->domainname) + 1); /* */ - /* search and domain are mutually exclusive */ + /* + * Search and domain are mutually exclusive. + */ for (i = 0 ; i < LWRES_CONFMAXSEARCH ; i++) { if (confdata->search[i] != NULL) { CTXFREE(confdata->search[i], @@ -286,8 +281,7 @@ lwres_conf_parsedomain(lwres_context_t *ctx, FILE *fp) } static lwres_result_t -lwres_conf_parsesearch(lwres_context_t *ctx, FILE *fp) -{ +lwres_conf_parsesearch(lwres_context_t *ctx, FILE *fp) { int idx, delim; char word[LWRES_CONFMAXLINELEN]; lwres_conf_t *confdata; @@ -295,13 +289,17 @@ lwres_conf_parsesearch(lwres_context_t *ctx, FILE *fp) confdata = &ctx->confdata; if (confdata->domainname != NULL) { - /* search and domain are mutually exclusive */ + /* + * Search and domain are mutually exclusive. + */ CTXFREE(confdata->domainname, strlen(confdata->domainname) + 1); confdata->domainname = NULL; } - /* remove any previous search definitions. */ + /* + * Remove any previous search definitions. + */ for (idx = 0 ; idx < LWRES_CONFMAXSEARCH ; idx++) { if (confdata->search[idx] != NULL) { CTXFREE(confdata->search[idx], @@ -313,12 +311,12 @@ lwres_conf_parsesearch(lwres_context_t *ctx, FILE *fp) delim = getword(fp, word, sizeof(word)); if (strlen(word) == 0) - return (LWRES_R_FAILURE); /* nothing else on line */ + return (LWRES_R_FAILURE); /* Nothing else on line. */ idx = 0; while (strlen(word) > 0) { if (confdata->searchnxt == LWRES_CONFMAXSEARCH) - return (LWRES_R_FAILURE); /* too many domains */ + return (LWRES_R_FAILURE); /* Too many domains. */ confdata->search[idx] = lwres_strdup(ctx, word); if (confdata->search[idx] == NULL) @@ -336,8 +334,7 @@ lwres_conf_parsesearch(lwres_context_t *ctx, FILE *fp) } static lwres_result_t -lwres_create_addr(const char *buffer, lwres_addr_t *addr) -{ +lwres_create_addr(const char *buffer, lwres_addr_t *addr) { unsigned char addrbuff[NS_IN6ADDRSZ]; unsigned int len; @@ -352,7 +349,7 @@ lwres_create_addr(const char *buffer, lwres_addr_t *addr) len = 16; #endif } else { - return (LWRES_R_FAILURE); /* unrecongnised format */ + return (LWRES_R_FAILURE); /* Unrecongnised format. */ } memcpy((void *)addr->address, addrbuff, len); @@ -361,8 +358,7 @@ lwres_create_addr(const char *buffer, lwres_addr_t *addr) } static lwres_result_t -lwres_conf_parsesortlist(lwres_context_t *ctx, FILE *fp) -{ +lwres_conf_parsesortlist(lwres_context_t *ctx, FILE *fp) { int delim, res, idx; char word[LWRES_CONFMAXLINELEN]; char *p; @@ -372,11 +368,11 @@ lwres_conf_parsesortlist(lwres_context_t *ctx, FILE *fp) delim = getword(fp, word, sizeof(word)); if (strlen(word) == 0) - return (LWRES_R_FAILURE); /* empty line after keyword */ + return (LWRES_R_FAILURE); /* Empty line after keyword. */ while (strlen(word) > 0) { if (confdata->sortlistnxt == LWRES_CONFMAXSORTLIST) - return (LWRES_R_FAILURE); /* too many values. */ + return (LWRES_R_FAILURE); /* Too many values. */ p = strchr(word, '/'); if (p != NULL) @@ -393,7 +389,9 @@ lwres_conf_parsesortlist(lwres_context_t *ctx, FILE *fp) if (res != LWRES_R_SUCCESS) return (res); } else { - /* Make up a mask. */ + /* + * Make up a mask. + */ confdata->sortlist[idx].mask = confdata->sortlist[idx].addr; @@ -426,7 +424,7 @@ lwres_conf_parseoption(lwres_context_t *ctx, FILE *fp) delim = getword(fp, word, sizeof(word)); if (strlen(word) == 0) - return (LWRES_R_FAILURE); /* empty line after keyword */ + return (LWRES_R_FAILURE); /* Empty line after keyword. */ while (strlen(word) > 0) { if (strcmp("debug", word) == 0) { @@ -435,7 +433,7 @@ lwres_conf_parseoption(lwres_context_t *ctx, FILE *fp) confdata->no_tld_query = 1; } else if (strncmp("ndots:", word, 6) == 0) { ndots = strtol(word + 6, &p, 10); - if (*p != '\0') /* bad string */ + if (*p != '\0') /* Bad string. */ return (LWRES_R_FAILURE); confdata->ndots = ndots; } @@ -450,8 +448,7 @@ lwres_conf_parseoption(lwres_context_t *ctx, FILE *fp) } lwres_result_t -lwres_conf_parse(lwres_context_t *ctx, const char *filename) -{ +lwres_conf_parse(lwres_context_t *ctx, const char *filename) { FILE *fp = NULL; char word[256]; int delim; @@ -495,8 +492,7 @@ lwres_conf_parse(lwres_context_t *ctx, const char *filename) } lwres_result_t -lwres_conf_print(lwres_context_t *ctx, FILE *fp) -{ +lwres_conf_print(lwres_context_t *ctx, FILE *fp) { int i; char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; const char *p; @@ -568,8 +564,7 @@ lwres_conf_print(lwres_context_t *ctx, FILE *fp) } lwres_conf_t * -lwres_conf_get(lwres_context_t *ctx) -{ +lwres_conf_get(lwres_context_t *ctx) { REQUIRE(ctx != NULL); return (&ctx->confdata); diff --git a/lib/lwres/lwinetaton.c b/lib/lwres/lwinetaton.c index e5b61e6165..47003d4175 100644 --- a/lib/lwres/lwinetaton.c +++ b/lib/lwres/lwinetaton.c @@ -70,7 +70,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; -static char rcsid[] = "$Id: lwinetaton.c,v 1.2 2000/02/04 06:50:06 halley Exp $"; +static char rcsid[] = "$Id: lwinetaton.c,v 1.3 2000/05/09 22:22:24 tale Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -90,8 +90,7 @@ static char rcsid[] = "$Id: lwinetaton.c,v 1.2 2000/02/04 06:50:06 halley Exp $" * cannot distinguish between failure and a local broadcast address. */ int -lwres_net_aton(const char *cp, struct in_addr *addr) -{ +lwres_net_aton(const char *cp, struct in_addr *addr) { unsigned long val; int base, n; char c; @@ -119,16 +118,21 @@ lwres_net_aton(const char *cp, struct in_addr *addr) } } for (;;) { - if (isascii(c & 0xff) && isdigit(c & 0xff)) { + /* + * isascii() is valid for all integer values, and + * when it is true, c is known to be in scope + * for isdigit(). No cast necessary. Similar + * comment applies for later ctype uses. + */ + if (isascii(c) && isdigit(c)) { if (base == 8 && (c == '8' || c == '9')) return (0); val = (val * base) + (c - '0'); c = *++cp; digit = 1; - } else if (base == 16 && isascii(c & 0xff) && - isxdigit(c & 0xff)) { + } else if (base == 16 && isascii(c) && isxdigit(c)) { val = (val << 4) | - (c + 10 - (islower(c & 0xff) ? 'a' : 'A')); + (c + 10 - (islower(c) ? 'a' : 'A')); c = *++cp; digit = 1; } else @@ -151,7 +155,7 @@ lwres_net_aton(const char *cp, struct in_addr *addr) /* * Check for trailing characters. */ - if (c != '\0' && (!isascii(c & 0xff) || !isspace(c & 0xff))) + if (c != '\0' && (!isascii(c) || !isspace(c))) return (0); /* * Did we get a valid digit? diff --git a/lib/tests/t_api.c b/lib/tests/t_api.c index fc80b5ff2b..751ecf3190 100644 --- a/lib/tests/t_api.c +++ b/lib/tests/t_api.c @@ -725,7 +725,7 @@ t_eval(char *filename, int (*func)(char **), int nargs) { /* * Skip comment lines. */ - if ((isspace((int)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) continue; cnt = t_bustline(p, tokens);