diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-09-04 23:31:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-09-04 23:31:35 +0000 |
commit | 3f63787cbfe0f1e837c92cd8ac35fd7ab811c18b (patch) | |
tree | 8fed7ef5dcf0af783bda9301eb664883e8c8eb83 /src/backend/libpq/pqformat.c | |
parent | c5214b9f6cf7b0a998c96c9be9c828aec3bc18cf (diff) |
Guard against send-lots-and-lots-of-data DoS attack from unauthenticated
users, by limiting the length of string we will accept for a password.
Patch by Serguei Mokhov, some editorializing by Tom Lane.
Diffstat (limited to 'src/backend/libpq/pqformat.c')
-rw-r--r-- | src/backend/libpq/pqformat.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c index 278835f2093..5f5acb44435 100644 --- a/src/backend/libpq/pqformat.c +++ b/src/backend/libpq/pqformat.c @@ -16,7 +16,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqformat.c,v 1.24 2002/09/03 21:45:42 petere Exp $ + * $Id: pqformat.c,v 1.25 2002/09/04 23:31:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -38,10 +38,10 @@ * pq_puttextmessage - generate a character set-converted message in one step * * Message input: - * pq_getint - get an integer from connection - * pq_getstr - get a null terminated string from connection - * pq_getstr performs character set conversion on the collected string. - * Use the raw pqcomm.c routines pq_getstring or pq_getbytes + * pq_getint - get an integer from connection + * pq_getstr_bounded - get a null terminated string from connection + * pq_getstr_bounded performs character set conversion on the collected + * string. Use the raw pqcomm.c routines pq_getstring or pq_getbytes * to fetch data without conversion. */ @@ -247,21 +247,23 @@ pq_getint(int *result, int b) } /* -------------------------------- - * pq_getstr - get a null terminated string from connection + * pq_getstr_bounded - get a null terminated string from connection * * The return value is placed in an expansible StringInfo. * Note that space allocation comes from the current memory context! * + * The maxlen parameter is interpreted as per pq_getstring. + * * returns 0 if OK, EOF if trouble * -------------------------------- */ int -pq_getstr(StringInfo s) +pq_getstr_bounded(StringInfo s, int maxlen) { int result; char *p; - result = pq_getstring(s); + result = pq_getstring(s, maxlen); p = (char *) pg_client_to_server((unsigned char *) s->data, s->len); if (p != s->data) /* actual conversion has been done? */ |