Re: [PATCH v2 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andy,

On Thu, Feb 15, 2024 at 1:19 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> On Thu, Feb 15, 2024 at 02:17:00PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 15, 2024 at 11:40:44AM +0100, Geert Uytterhoeven wrote:
> > > On Mon, Feb 12, 2024 at 6:04 PM Andy Shevchenko
> > > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > > +       linedisp->buf = buf ? buf : linedisp->curr;
> > > > +       linedisp->num_chars = buf ? num_chars : min(num_chars, LINEDISP_DEFAULT_BUF_SZ);
> > >
> > > I think it would be safer to return an error if buf == NULL and
> > > num_chars < LINEDISP_DEFAULT_BUF_SZ.
> >
> > I think you meant >= ?

Oops, yes/

> >
> > > Else a careless driver that doesn't check linedisp->num_chars might
> > > overflow the buffer.
> >
> > Okay, check has been added.
>
> Hold on, but I have min() being called, isn't it enough?

Yes you have.

A careless driver might not use linedisp->num_chars later, but instead
just hardcode e.g. memcpy(linedisp->buf, source, LARGE_BUF_SIZE).

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux