Fix some buffer underflows

This commit is contained in:
Pasi Kallinen
2018-11-08 21:02:24 +02:00
parent afd793e9b7
commit f9f1236f26

View File

@@ -2086,6 +2086,7 @@ const char *const *alt_as_is; /* another set like as_is[] */
const struct sing_plur *sp;
const char *same, *other, *const *as;
int al;
int baselen = strlen(basestr);
for (as = as_is; *as; ++as) {
al = (int) strlen(*as);
@@ -2112,20 +2113,20 @@ const char *const *alt_as_is; /* another set like as_is[] */
}
/* skip "ox" -> "oxen" entry when pluralizing "<something>ox"
unless it is muskox */
if (to_plural && strlen(basestr) > 2 && !strcmpi(endstring - 2, "ox")
&& strcmpi(endstring - 6, "muskox")) {
if (to_plural && baselen > 2 && !strcmpi(endstring - 2, "ox")
&& baselen > 5 && strcmpi(endstring - 6, "muskox")) {
/* "fox" -> "foxes" */
Strcasecpy(endstring, "es");
return TRUE;
}
if (to_plural) {
if (!strcmpi(endstring - 3, "man")
if (baselen > 2 && !strcmpi(endstring - 3, "man")
&& badman(basestr, to_plural)) {
Strcasecpy(endstring, "s");
return TRUE;
}
} else {
if (!strcmpi(endstring - 3, "men")
if (baselen > 2 && !strcmpi(endstring - 3, "men")
&& badman(basestr, to_plural))
return TRUE;
}