~ubuntu-branches/ubuntu/utopic/postgresql-9.4/utopic-security

« back to all changes in this revision

Viewing changes to src/backend/bootstrap/bootstrap.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, CVE-2014-8161
  • Date: 2015-02-06 12:31:46 UTC
  • mfrom: (1.1.5) (7.1.2 utopic-proposed)
  • Revision ID: package-import@ubuntu.com-20150206123146-vtmf30jbkm7w16p8
Tags: 9.4.1-0ubuntu0.14.10
* New upstream security/bug fix release (LP: #1418928)
  - Fix buffer overruns in to_char() [CVE-2015-0241]
  - Fix buffer overruns in contrib/pgcrypto [CVE-2015-0243]
  - Fix possible loss of frontend/backend protocol synchronization after an
    error [CVE-2015-0244]
  - Fix information leak via constraint-violation error messages
    [CVE-2014-8161]
  - See release notes for details about other fixes:
    http://www.postgresql.org/about/news/1569/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1032
1032
        return attribute;
1033
1033
}
1034
1034
 
1035
 
/* ----------------
 
1035
/*
1036
1036
 *              MapArrayTypeName
1037
 
 * XXX arrays of "basetype" are always "_basetype".
1038
 
 *         this is an evil hack inherited from rel. 3.1.
1039
 
 * XXX array dimension is thrown away because we
1040
 
 *         don't support fixed-dimension arrays.  again,
1041
 
 *         sickness from 3.1.
1042
 
 *
1043
 
 * the string passed in must have a '[' character in it
1044
 
 *
1045
 
 * the string returned is a pointer to static storage and should NOT
1046
 
 * be freed by the CALLER.
1047
 
 * ----------------
 
1037
 *
 
1038
 * Given a type name, produce the corresponding array type name by prepending
 
1039
 * '_' and truncating as needed to fit in NAMEDATALEN-1 bytes.  This is only
 
1040
 * used in bootstrap mode, so we can get away with assuming that the input is
 
1041
 * ASCII and we don't need multibyte-aware truncation.
 
1042
 *
 
1043
 * The given string normally ends with '[]' or '[digits]'; we discard that.
 
1044
 *
 
1045
 * The result is a palloc'd string.
1048
1046
 */
1049
1047
char *
1050
 
MapArrayTypeName(char *s)
 
1048
MapArrayTypeName(const char *s)
1051
1049
{
1052
1050
        int                     i,
1053
1051
                                j;
1054
 
        static char newStr[NAMEDATALEN];        /* array type names < NAMEDATALEN long */
1055
 
 
1056
 
        if (s == NULL || s[0] == '\0')
1057
 
                return s;
1058
 
 
 
1052
        char            newStr[NAMEDATALEN];
 
1053
 
 
1054
        newStr[0] = '_';
1059
1055
        j = 1;
1060
 
        newStr[0] = '_';
1061
 
        for (i = 0; i < NAMEDATALEN - 1 && s[i] != '['; i++, j++)
 
1056
        for (i = 0; i < NAMEDATALEN - 2 && s[i] != '['; i++, j++)
1062
1057
                newStr[j] = s[i];
1063
1058
 
1064
1059
        newStr[j] = '\0';
1065
1060
 
1066
 
        return newStr;
 
1061
        return pstrdup(newStr);
1067
1062
}
1068
1063
 
1069
1064