Re: 9.6.10 build warning on Fedora 28

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Devrim Gündüz <devrim(at)gunduz(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: 9.6.10 build warning on Fedora 28
Date: 2018-08-09 09:53:46
Message-ID: CAKJS1f9pqgY+OFeDw66T+rZMWXSCHKB_vafoK329kb47t=fKkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9 August 2018 at 21:30, Devrim Gündüz <devrim(at)gunduz(dot)org> wrote:
> pgbench.c: In function 'ParseScript':
> pgbench.c:2640:20: warning: '__builtin___sprintf_chk' may write a terminating
> nul past the end of the destination [-Wformat-overflow=]
> sprintf(var, "$%d", cmd->argc);
> ^
> In file included from /usr/include/stdio.h:862,
> from ../../../src/include/c.h:81,
> from ../../../src/include/postgres_fe.h:25,
> from pgbench.c:34:
> /usr/include/bits/stdio2.h:33:10: note: '__builtin___sprintf_chk' output
> between 3 and 13 bytes into a destination of size 12
> return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> __bos (__s), __fmt, __va_arg_pack ());

Generally, new warnings from newer compilers are not fixed in older
branches. This particular warning was fixed in master in [1] and the
discussion was in [2].

The warning is pretty false anyway since cmd->argc won't be negative.

[1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=3a4b891964a531aa7d242a48fcd9e41379863ead
[2] https://www.postgresql.org/message-id/304a21ab-a9d6-264a-f688-912869c0d7c6@2ndquadrant.com

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message KES 2018-08-09 10:11:05 Re: Typo in doc or wrong EXCLUDE implementation
Previous Message Kyotaro HORIGUCHI 2018-08-09 09:42:16 Re: [PATCH] Improve geometric types