Fix too small buffer size in some configuration file process.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 16 Aug 2018 06:38:33 +0000 (15:38 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 16 Aug 2018 06:41:26 +0000 (15:41 +0900)
This was found by newer version of gcc warnings.

pool_config_variables.c: In function ‘BackendFlagsShowFunc’:
pool_config_variables.c:3809:57: warning: ‘__builtin_snprintf’ output truncated before the last format character [-Wformat-truncation=]
   snprintf(buffer, sizeof(buffer), "DISALLOW_TO_FAILOVER");
                                                         ^
In file included from /usr/include/stdio.h:862:0,
                 from pool_config_variables.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin_snprintf’ output 21 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/config/pool_config_variables.c

index 3ab803f1513e73e947aae1827c1da2b39a5d36ca..0c9b62d6ce121c52a0205cc3cd049354ec9fea23 100644 (file)
@@ -3652,7 +3652,7 @@ static const char* BackendDataDirShowFunc(int index)
 
 static const char* BackendFlagsShowFunc(int index)
 {
-       static char buffer[20];
+       static char buffer[21];
 
        unsigned short flag = g_pool_config.backend_desc->backend_info[index].flag;
        if (POOL_ALLOW_TO_FAILOVER(flag))