[virglrenderer-devel] [PATCH 01/10] shader: bump some snprintf limits to 512
Gert Wollny
gert.wollny at collabora.com
Mon Jul 30 12:49:25 UTC 2018
Am Montag, den 30.07.2018, 14:51 +1000 schrieb Dave Airlie:
> On 25 July 2018 at 20:53, Erik Faye-Lund <erik.faye-lund at collabora.co
> m> wrote:
> > I saw things like this in the past causing some rebase-issues, and
> > I wonder
> > why we don't just do "snprintf(buf, sizeof(buf), ...)" instead?
> > That way,
> > we'd just have to update the buffer-size in one place once we know
> > it's too
> > small...
>
> Yeah I think we should probably do that cleanup once we land all of
> this gles stuff.
>
> I build with format warnings, and it's a big mess, I think we've got
> a
> bit of cleaning
> up to do in this area anyways.
>
> like should it be snprintf(buf, sizeof(buf)-1? should we explicitly
> stick a \0 in there,
This is not needed if glibc >= 2.0.6 (from the man page):
"The functions snprintf() and vsnprintf() write at most size bytes
(including the terminating null byte ('\0')) to str.
...
If truncation occurs in glibc versions prior to 2.0.6, this is treated
as an error instead of being handled gracefully."
best,
Gert
More information about the virglrenderer-devel
mailing list