~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-proposed

« back to all changes in this revision

Viewing changes to src/interfaces/libpq/fe-misc.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-07-24 16:13:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140724161359-uk325qfv03euxuuh
Tags: 9.3.5-0ubuntu0.14.04.1
* New upstream bug fix release: (LP: #1348176)
  - pg_upgrade: Users who upgraded to version 9.3 using pg_upgrade may have
    an issue with transaction information which causes VACUUM to eventually
    fail. These users should run the script provided in the release notes to
    determine if their installation is affected, and then take the remedy
    steps outlined there.
  - Various data integrity and other bug fixes.
  - Secure Unix-domain sockets of temporary postmasters started during make
    check.
    Any local user able to access the socket file could connect as the
    server's bootstrap superuser, then proceed to execute arbitrary code as
    the operating-system user running the test, as we previously noted in
    CVE-2014-0067. This change defends against that risk by placing the
    server's socket in a temporary, mode 0700 subdirectory of /tmp.
  - See release notes for details:
    http://www.postgresql.org/about/news/1534/
* Remove pg_regress patches to support --host=/path, obsolete with above
  upstream changes and not applicable any more.
* Drop tcl8.6 patch, applied upstream.
* Add missing logrotate test dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
351
351
        int                     newsize = conn->outBufSize;
352
352
        char       *newbuf;
353
353
 
 
354
        /* Quick exit if we have enough space */
354
355
        if (bytes_needed <= (size_t) newsize)
355
356
                return 0;
356
357
 
414
415
        int                     newsize = conn->inBufSize;
415
416
        char       *newbuf;
416
417
 
 
418
        /* Quick exit if we have enough space */
 
419
        if (bytes_needed <= (size_t) newsize)
 
420
                return 0;
 
421
 
 
422
        /*
 
423
         * Before concluding that we need to enlarge the buffer, left-justify
 
424
         * whatever is in it and recheck.  The caller's value of bytes_needed
 
425
         * includes any data to the left of inStart, but we can delete that in
 
426
         * preference to enlarging the buffer.  It's slightly ugly to have this
 
427
         * function do this, but it's better than making callers worry about it.
 
428
         */
 
429
        bytes_needed -= conn->inStart;
 
430
 
 
431
        if (conn->inStart < conn->inEnd)
 
432
        {
 
433
                if (conn->inStart > 0)
 
434
                {
 
435
                        memmove(conn->inBuffer, conn->inBuffer + conn->inStart,
 
436
                                        conn->inEnd - conn->inStart);
 
437
                        conn->inEnd -= conn->inStart;
 
438
                        conn->inCursor -= conn->inStart;
 
439
                        conn->inStart = 0;
 
440
                }
 
441
        }
 
442
        else
 
443
        {
 
444
                /* buffer is logically empty, reset it */
 
445
                conn->inStart = conn->inCursor = conn->inEnd = 0;
 
446
        }
 
447
 
 
448
        /* Recheck whether we have enough space */
417
449
        if (bytes_needed <= (size_t) newsize)
418
450
                return 0;
419
451
 
681
713
                /*
682
714
                 * Hack to deal with the fact that some kernels will only give us back
683
715
                 * 1 packet per recv() call, even if we asked for more and there is
684
 
                 * more available.      If it looks like we are reading a long message,
 
716
                 * more available.  If it looks like we are reading a long message,
685
717
                 * loop back to recv() again immediately, until we run out of data or
686
718
                 * buffer space.  Without this, the block-and-restart behavior of
687
719
                 * libpq's higher levels leads to O(N^2) performance on long messages.
688
720
                 *
689
721
                 * Since we left-justified the data above, conn->inEnd gives the
690
 
                 * amount of data already read in the current message.  We consider
 
722
                 * amount of data already read in the current message.  We consider
691
723
                 * the message "long" once we have acquired 32k ...
692
724
                 */
693
725
                if (conn->inEnd > 32768 &&