Make some use of reallocarray, attempting to limit it to cases where the
parameters are unsigned and there is some theoretical chance of overflow.
MFC afer: 2 weeks
Differential Revision: https://reviews.freebsd.org/D9980
if (eof)
break;
while ((size_t)(q - p) >= size) {
- if ((tmp = realloc(buf, size * 2)) == NULL) {
+ if ((tmp = reallocarray(buf, 2, size)) == NULL) {
warnx("group line too long");
goto err;
}
if (sz <= internal_arraysz)
p = internal_array;
- else if ((p = realloc(internal_array, sz * sizeof(char*))) != NULL) {
+ else if ((p = reallocarray(internal_array, sz, sizeof(char*))) != NULL) {
internal_arraysz = sz;
internal_array = p;
}
if (eof)
break;
while ((size_t)(q - p) >= size) {
- if ((tmp = realloc(buf, size * 2)) == NULL) {
+ if ((tmp = reallocarray(buf, 2, size)) == NULL) {
warnx("passwd line too long");
goto err;
}