~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/backend/executor/nodeCtescan.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-02-05 18:13:52 UTC
  • mfrom: (1.1.10) (10.1.5 oneiric-proposed)
  • Revision ID: package-import@ubuntu.com-20130205181352-3kw4f94ilqklzm7c
Tags: 9.1.8-0ubuntu11.10
* New upstream security/bug fix release: (LP: #1116336)
  - Prevent execution of enum_recv from SQL
    The function was misdeclared, allowing a simple SQL command to crash the
    server.  In principle an attacker might be able to use it to examine the
    contents of server memory.  Our thanks to Sumit Soni (via Secunia SVCRP)
    for reporting this issue. (CVE-2013-0255)
  - See HISTORY/changelog.gz for the other bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
         * The Param slot associated with the CTE query is used to hold a pointer
206
206
         * to the CteState of the first CteScan node that initializes for this
207
207
         * CTE.  This node will be the one that holds the shared state for all the
208
 
         * CTEs.
 
208
         * CTEs, particularly the shared tuplestore.
209
209
         */
210
210
        prmdata = &(estate->es_param_exec_vals[node->cteParam]);
211
211
        Assert(prmdata->execPlan == NULL);
294
294
         * If I am the leader, free the tuplestore.
295
295
         */
296
296
        if (node->leader == node)
 
297
        {
297
298
                tuplestore_end(node->cte_table);
 
299
                node->cte_table = NULL;
 
300
        }
298
301
}
299
302
 
300
303
/* ----------------------------------------------------------------
312
315
 
313
316
        ExecScanReScan(&node->ss);
314
317
 
315
 
        if (node->leader == node)
 
318
        /*
 
319
         * Clear the tuplestore if a new scan of the underlying CTE is required.
 
320
         * This implicitly resets all the tuplestore's read pointers.  Note that
 
321
         * multiple CTE nodes might redundantly clear the tuplestore; that's OK,
 
322
         * and not unduly expensive.  We'll stop taking this path as soon as
 
323
         * somebody has attempted to read something from the underlying CTE
 
324
         * (thereby causing its chgParam to be cleared).
 
325
         */
 
326
        if (node->leader->cteplanstate->chgParam != NULL)
 
327
        {
 
328
                tuplestore_clear(tuplestorestate);
 
329
                node->leader->eof_cte = false;
 
330
        }
 
331
        else
316
332
        {
317
333
                /*
318
 
                 * The leader is responsible for clearing the tuplestore if a new scan
319
 
                 * of the underlying CTE is required.
 
334
                 * Else, just rewind my own pointer.  Either the underlying CTE
 
335
                 * doesn't need a rescan (and we can re-read what's in the tuplestore
 
336
                 * now), or somebody else already took care of it.
320
337
                 */
321
 
                if (node->cteplanstate->chgParam != NULL)
322
 
                {
323
 
                        tuplestore_clear(tuplestorestate);
324
 
                        node->eof_cte = false;
325
 
                }
326
 
                else
327
 
                {
328
 
                        tuplestore_select_read_pointer(tuplestorestate, node->readptr);
329
 
                        tuplestore_rescan(tuplestorestate);
330
 
                }
331
 
        }
332
 
        else
333
 
        {
334
 
                /* Not leader, so just rewind my own pointer */
335
338
                tuplestore_select_read_pointer(tuplestorestate, node->readptr);
336
339
                tuplestore_rescan(tuplestorestate);
337
340
        }