Use scnprint instead of snprintf, because snprintf returns the number of bytes
that would have been written to the buffer if there was enough space, and as a
result writing to buf[len-1] might cause a access beyond the buffers limits.
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Lars-Peter Clausen <[email protected]>
Acked-by: Jonathan Cameron <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
return 0;
for (i = 0; i < e->num_items; ++i)
- len += snprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
+ len += scnprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
/* replace last space with a newline */
buf[len - 1] = '\n';