On Mon, Sep 30, 2024 at 6:05 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > Robert Haas <robertmh...@gmail.com> writes: > > On Mon, Sep 30, 2024 at 11:31 AM Tom Lane <t...@sss.pgh.pa.us> wrote: > >> WFM, modulo the suggestion about changing data types. > > > I would prefer not to make the data type change here because it has > > quite a few tentacles. > > I see your point for the function's "len" argument, but perhaps it's > worth doing > > - int remaining; > + size_t remaining; > > remaining = sizeof(ControlFileData) - mystreamer->control_file_bytes; > memcpy(((char *) &mystreamer->control_file) > + mystreamer->control_file_bytes, > - data, Min(len, remaining)); > + data, Min((size_t) len, remaining)); > > This is enough to ensure the Min() remains safe.
OK, done! -- Robert Haas EDB: http://www.enterprisedb.com