lkml.org 
[lkml]   [2020]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] RDMA/ocrdma: Fix an off-by-one issue in 'ocrdma_add_stat'
On Tue, Apr 14, 2020 at 03:34:41PM -0300, Jason Gunthorpe wrote:
> The memcpy is still kind of silly right? What about this:
>
> static int ocrdma_add_stat(char *start, char *pcur, char *name, u64 count)
> {
> size_t len = (start + OCRDMA_MAX_DBGFS_MEM) - pcur;
> int cpy_len;
>
> cpy_len = snprintf(pcur, len, "%s: %llu\n", name, count);
> if (cpy_len >= len || cpy_len < 0) {

The kernel version of snprintf() doesn't and will never return
negatives. It would cause a huge security headache if it started
returning negatives.

> pr_err("%s: No space in stats buff\n", __func__);
> return 0;
> }

regards,
dan carpenter

\
 
 \ /
  Last update: 2020-04-16 15:11    [W:0.127 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site