Fix to check the return value of strchr() in Pgversion().
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 6 Jul 2019 23:24:16 +0000 (08:24 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 6 Jul 2019 23:24:16 +0000 (08:24 +0900)
Pointed out by Coverity.

src/protocol/child.c

index 6d49c2c709e31492f452e0999ba4d279333f7c8c..ecc797b884aef9845f5d011c5a483c951f6d98df 100644 (file)
@@ -2538,6 +2538,13 @@ Pgversion(POOL_CONNECTION_POOL * backend)
         * valid digit (in our case 'b')). So "12beta1" should be converted to 12.
         */
        p = strchr(result, ' ');
+       if (p == NULL)
+       {
+               ereport(FATAL,
+                               (errmsg("Pgversion: unable to find the first space in the version string: %s", result)));
+               return NULL;
+       }
+
        p++;
        i = 0;
        while (i < VERSION_BUF_SIZE - 1 && p && *p != '.')