forked from github/server
CID 22568: Copy into fixed size buffer (STRING_OVERFLOW)
more bsdstring replacements
This commit is contained in:
parent
e69635d697
commit
51f66b8da8
17
src/names.c
17
src/names.c
|
@ -281,22 +281,23 @@ static const char *dragon_name(const unit * u)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char n[32];
|
char n[32];
|
||||||
|
size_t sz;
|
||||||
|
|
||||||
strcpy(n, silbe1[rng_int() % SIL1]);
|
sz = strlcpy(n, silbe1[rng_int() % SIL1], sizeof(n));
|
||||||
strcat(n, silbe2[rng_int() % SIL2]);
|
sz += strlcat(n, silbe2[rng_int() % SIL2], sizeof(n));
|
||||||
strcat(n, silbe3[rng_int() % SIL3]);
|
sz += strlcat(n, silbe3[rng_int() % SIL3], sizeof(n));
|
||||||
if (rng_int() % 5 > 2) {
|
if (rng_int() % 5 > 2) {
|
||||||
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
|
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strcpy(name, (const char *)str); /* "Der Titel Name" */
|
sz = strlcpy(name, (const char *)str, sizeof(name)); /* "Der Titel Name" */
|
||||||
name[0] = (char)toupper(name[0]); /* TODO: UNICODE - should use towupper() */
|
name[0] = (char)toupper(name[0]); /* TODO: UNICODE - should use towupper() */
|
||||||
strcat(name, " ");
|
sz += strlcat(name, " ", sizeof(name));
|
||||||
strcat(name, n);
|
sz += strlcat(name, n, sizeof(name));
|
||||||
}
|
}
|
||||||
if (u && (rng_int() % 3 == 0)) {
|
if (u && (rng_int() % 3 == 0)) {
|
||||||
strcat(name, " von ");
|
sz += strlcat(name, " von ", sizeof(name));
|
||||||
strcat(name, (const char *)rname(u->region, default_locale));
|
sz += strlcat(name, (const char *)rname(u->region, default_locale), sizeof(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue