It's unlikely that we'll ever want to escape a string as long as
INT_MAX/6, but adding this check can't hurt.
* src/util/buf.c (virBufferEscapeSexpr, virBufferEscapeString):
Check for (unlikely) overflow.
return;
}
- if (VIR_ALLOC_N(escaped, 6 * len + 1) < 0) {
+ if (xalloc_oversized(6, len) ||
+ VIR_ALLOC_N(escaped, 6 * len + 1) < 0) {
virBufferSetError(buf);
return;
}
return;
}
- if (VIR_ALLOC_N(escaped, 2 * len + 1) < 0) {
+ if (xalloc_oversized(2, len) ||
+ VIR_ALLOC_N(escaped, 2 * len + 1) < 0) {
virBufferSetError(buf);
return;
}