* [PATCH] fds/drm.c: Increase buffer size.
@ 2017-02-28 19:49 Vinson Lee
[not found] ` <20170228210855.sj2zpdw3fusqh4hv@codemonkey.org.uk>
0 siblings, 1 reply; 3+ messages in thread
From: Vinson Lee @ 2017-02-28 19:49 UTC (permalink / raw)
To: trinity
Fix GCC format-truncation error.
CC fds/drm.o
fds/drm.c: In function ‘open_drm_fds’:
fds/drm.c:106:40: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 119 [-Werror=format-truncation=]
snprintf(buf, sizeof(buf), "/dev/dri/%s", entry->d_name);
^~
In file included from /usr/include/stdio.h:939:0,
from include/list.h:3,
from include/fd.h:3,
from fds/drm.c:4:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 10 and 265 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
fds/drm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fds/drm.c b/fds/drm.c
index 1f7b95f1eb34..b094183d8d0d 100644
--- a/fds/drm.c
+++ b/fds/drm.c
@@ -83,7 +83,7 @@ static int open_drm_fds(void)
int fd, dfd;
DIR *dir;
struct dirent *entry;
- char buf[128];
+ char buf[512];
head = get_objhead(OBJ_GLOBAL, OBJ_FD_DRM);
head->destroy = &drmfd_destructor;
--
2.11.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fds/drm.c: Increase buffer size.
[not found] ` <20170228210855.sj2zpdw3fusqh4hv@codemonkey.org.uk>
@ 2017-02-28 22:59 ` Vinson Lee
2017-02-28 23:02 ` Dave Jones
0 siblings, 1 reply; 3+ messages in thread
From: Vinson Lee @ 2017-02-28 22:59 UTC (permalink / raw)
To: Dave Jones; +Cc: trinity
On Tue, Feb 28, 2017 at 4:08 PM, Dave Jones <davej@codemonkey.org.uk> wrote:
> On Tue, Feb 28, 2017 at 07:49:16PM +0000, Vinson Lee wrote:
> > Fix GCC format-truncation error.
> >
> > CC fds/drm.o
> > fds/drm.c: In function ‘open_drm_fds’:
> > fds/drm.c:106:40: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 119 [-Werror=format-truncation=]
> > snprintf(buf, sizeof(buf), "/dev/dri/%s", entry->d_name);
> > ^~
> > In file included from /usr/include/stdio.h:939:0,
> > from include/list.h:3,
> > from include/fd.h:3,
> > from fds/drm.c:4:
> > /usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 10 and 265 bytes into a destination of size 128
> > return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > __bos (__s), __fmt, __va_arg_pack ());
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Signed-off-by: Vinson Lee <vlee@freedesktop.org>
> > ---
> > fds/drm.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fds/drm.c b/fds/drm.c
> > index 1f7b95f1eb34..b094183d8d0d 100644
> > --- a/fds/drm.c
> > +++ b/fds/drm.c
> > @@ -83,7 +83,7 @@ static int open_drm_fds(void)
> > int fd, dfd;
> > DIR *dir;
> > struct dirent *entry;
> > - char buf[128];
> > + char buf[512];
>
> d_name is only 256. Does 256+10 make the error go away ?
>
> I don't think this is ever a problem in real life, because no-one is
> insane enough to name a device node in that dir that long, but we should
> shut the warning up.
>
> Is this a gcc7 thing ?
>
> Dave
>
Yes, buf[256+10] also fixes the build error.
Yes, this build error occurs with 7.0.
Vinson
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fds/drm.c: Increase buffer size.
2017-02-28 22:59 ` Vinson Lee
@ 2017-02-28 23:02 ` Dave Jones
0 siblings, 0 replies; 3+ messages in thread
From: Dave Jones @ 2017-02-28 23:02 UTC (permalink / raw)
To: Vinson Lee; +Cc: trinity
On Tue, Feb 28, 2017 at 05:59:24PM -0500, Vinson Lee wrote:
> > > diff --git a/fds/drm.c b/fds/drm.c
> > > index 1f7b95f1eb34..b094183d8d0d 100644
> > > --- a/fds/drm.c
> > > +++ b/fds/drm.c
> > > @@ -83,7 +83,7 @@ static int open_drm_fds(void)
> > > int fd, dfd;
> > > DIR *dir;
> > > struct dirent *entry;
> > > - char buf[128];
> > > + char buf[512];
> >
> > d_name is only 256. Does 256+10 make the error go away ?
> >
> > I don't think this is ever a problem in real life, because no-one is
> > insane enough to name a device node in that dir that long, but we should
> > shut the warning up.
> >
> > Is this a gcc7 thing ?
> >
> > Dave
> >
>
> Yes, buf[256+10] also fixes the build error.
>
> Yes, this build error occurs with 7.0.
Cool, I'll hack up your mail and apply it.
thanks,
Dave
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-28 23:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-28 19:49 [PATCH] fds/drm.c: Increase buffer size Vinson Lee
[not found] ` <20170228210855.sj2zpdw3fusqh4hv@codemonkey.org.uk>
2017-02-28 22:59 ` Vinson Lee
2017-02-28 23:02 ` Dave Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).