The old code relied on implictly casting negative numbers to size_t
making a very large limit, which was correct but non-obvious.
Coverity CID
1128575
Signed-off-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
static char *string(char *str, char *end, const char *s,
int field_width, int precision, int flags)
{
- int i, len = strnlen(s, precision);
+ int i, len = (precision < 0) ? strlen(s) : strnlen(s, precision);
if (!(flags & LEFT)) {
while (len < field_width--) {