Fix query cache module so that it checks oid array's bound.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 7 Jul 2019 01:09:25 +0000 (10:09 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 7 Jul 2019 01:09:25 +0000 (10:09 +0900)
src/query_cache/pool_memqcache.c

index ed0c94dde414b199e3c893c428c80eeb000354e1..ef84cdc03c1f34e7e5674641195ef7b061ab44cf 100644 (file)
@@ -1195,7 +1195,7 @@ pool_extract_table_oids(Node *node, int **oidsp)
 
                foreach(cell, stmt->relations)
                {
-                       if (num_oids > POOL_MAX_DML_OIDS)
+                       if (num_oids >= POOL_MAX_DML_OIDS)
                        {
                                ereport(LOG,
                                                (errmsg("memcache: error while extracting table oids. too many oids:%d", num_oids)));
@@ -1223,6 +1223,13 @@ pool_extract_table_oids(Node *node, int **oidsp)
        oid = pool_table_name_to_oid(table);
        if (oid > 0)
        {
+               if (num_oids >= POOL_MAX_DML_OIDS)
+               {
+                       ereport(LOG,
+                                       (errmsg("memcache: error while extracting table oids. too many oids:%d", num_oids)));
+                       return 0;
+               }
+
                oids[num_oids++] = pool_table_name_to_oid(table);
                ereport(DEBUG1,
                                (errmsg("memcache: extracting table oids: table: \"%s\" oid:%d", table, oid)));