[pgpool-hackers: 3990] Re: gcc warnings
Tatsuo Ishii
ishii at sraoss.co.jp
Thu Aug 5 09:01:30 JST 2021
> After upgrading to Ubuntu 20 (from 18), I noticed I get tons of
> compiler warnings something like this:
>
> gcc -DHAVE_CONFIG_H -DDEFAULT_CONFIGDIR=\"/usr/local/etc\" -DPOOL_TOOLS -I. -I../../../src/include -D_GNU_SOURCE -DPOOL_PRIVATE -I /usr/local/pgsql/include -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -c -o pg_md5.o pg_md5.c
> In file included from /usr/include/string.h:495,
> from pg_md5.c:31:
> In function 。strncpy「,
> inlined from 。update_pool_passwd_from_file「 at pg_md5.c:283:3,
> inlined from 。main「 at pg_md5.c:136:3:
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: 。__builtin___strncpy_chk「 specified bound depends on the length of the source argument [-Wstringop-overflow=]
> 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> pg_md5.c: In function 。main「:
> pg_md5.c:278:7: note: length computed here
> 278 | if (strlen(pch) >= sizeof(password))
> | ^~~~~~~~~~~
>
> Basically this comlains that for this:
>
> strncpy(password, pch, strlen(pch));
>
> the third parameter should be the size of the destination (password),
> not the source (pch). Ok, so I fixed this to:
>
> strncpy(password, pch, sizeof(password));
>
> But then I get:
>
> In file included from /usr/include/string.h:495,
> from pg_md5.c:31:
> In function 。strncpy「,
> inlined from 。update_pool_passwd_from_file「 at pg_md5.c:276:3,
> inlined from 。main「 at pg_md5.c:136:3:
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: 。__builtin___strncpy_chk「 output may be truncated copying between 0 and 128 bytes from a string of length 257 [-Wstringop-truncation]
> 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I have found a message in PostgreSQL hackers mailing list regarding similar issue:
> https://www.postgresql.org/message-id/flat/21789.1529170195%40sss.pgh.pa.us#525c384d13505fa6f1f25c50b00d7a08
>
> It seems the solution for this is, add -Wno-stringop-truncation to
> CFLAG. After adding the parameter to the CLFAG, the annoying warning
> disappeared.
>
> So I am looking forward to change configure in this
> direction. Comments?
Patch for configure.ac attached.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.ac.diff
Type: text/x-patch
Size: 507 bytes
Desc: not available
URL: <http://www.pgpool.net/pipermail/pgpool-hackers/attachments/20210805/dee8a201/attachment.bin>
More information about the pgpool-hackers
mailing list