diff options
author | Yang Tse <yangsita@gmail.com> | 2009-05-29 13:19:51 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2009-05-29 13:19:51 +0000 |
commit | bef1b140e9253d32e87d1258de48594dc8325265 (patch) | |
tree | e1df07a575b60e75ea06ffa5a1e7b4c51eb9623e | |
parent | c9188e22609a453a0b67109328e0aa8fa040ef0b (diff) |
Fix compiler warning: out of bound access
-rw-r--r-- | ares/acountry.c | 11 | ||||
-rw-r--r-- | ares/adig.c | 15 |
2 files changed, 17 insertions, 9 deletions
diff --git a/ares/acountry.c b/ares/acountry.c index 1899ae962..69aaeb115 100644 --- a/ares/acountry.c +++ b/ares/acountry.c @@ -612,9 +612,14 @@ static void find_country_from_cname(const char *cname, struct in_addr addr) printf("Name for country-number %d not found.\n", cnumber); else { - if (ver_1 && *(unsigned short*)&country->short_name != *(unsigned*)&ccode_A2) - printf("short-name mismatch; %s vs %s\n", country->short_name, ccode_A2); - + if (ver_1) + { + if ((country->short_name[0] != ccode_A2[0]) || + (country->short_name[1] != ccode_A2[1]) || + (country->short_name[2] != ccode_A2[2])) + printf("short-name mismatch; %s vs %s\n", + country->short_name, ccode_A2); + } printf("%s (%s), number %d.\n", country->long_name, country->short_name, cnumber); } diff --git a/ares/adig.c b/ares/adig.c index c218e4696..9a3922d13 100644 --- a/ares/adig.c +++ b/ares/adig.c @@ -219,9 +219,10 @@ int main(int argc, char **argv) if (strcmp(flags[i].name, optarg) == 0) break; } - if (i == nflags) + if (i < nflags) + options.flags |= flags[i].value; + else usage(); - options.flags |= flags[i].value; break; case 's': @@ -256,9 +257,10 @@ int main(int argc, char **argv) if (strcasecmp(classes[i].name, optarg) == 0) break; } - if (i == nclasses) + if (i < nclasses) + dnsclass = classes[i].value; + else usage(); - dnsclass = classes[i].value; break; case 't': @@ -268,9 +270,10 @@ int main(int argc, char **argv) if (strcasecmp(types[i].name, optarg) == 0) break; } - if (i == ntypes) + if (i < ntypes) + type = types[i].value; + else usage(); - type = types[i].value; break; case 'T': |