Skip to content

Commit 3e87302

Browse files
committed
libpq's pqGetnchar() should not return a null-terminated value
anymore. Fix for large objects.
1 parent b9b00d5 commit 3e87302

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/interfaces/libpq/fe-exec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.62 1998/08/17 03:50:35 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.63 1998/08/29 02:09:24 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -612,6 +612,7 @@ getAnotherTuple(PGconn *conn, int binary)
612612
if (vlen > 0)
613613
if (pqGetnchar((char *) (tup[i].value), vlen, conn))
614614
return EOF;
615+
/* we have to terminate this ourselves */
615616
tup[i].value[vlen] = '\0';
616617
}
617618
/* advance the bitmap stuff */

src/interfaces/libpq/fe-misc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
*
2626
* IDENTIFICATION
27-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.18 1998/08/17 03:50:38 scrappy Exp $
27+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.19 1998/08/29 02:09:25 momjian Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -160,8 +160,7 @@ pqPuts(const char *s, PGconn *conn)
160160

161161
/* --------------------------------------------------------------------- */
162162
/* pqGetnchar:
163-
get a string of exactly len bytes in buffer s (which must be 1 byte
164-
longer) and terminate it with a '\0'.
163+
get a string of exactly len bytes in buffer s, no null termination
165164
*/
166165
int
167166
pqGetnchar(char *s, int len, PGconn *conn)
@@ -170,8 +169,8 @@ pqGetnchar(char *s, int len, PGconn *conn)
170169
return EOF;
171170

172171
memcpy(s, conn->inBuffer + conn->inCursor, len);
173-
s[len] = '\0';
174-
172+
/* no terminating null */
173+
175174
conn->inCursor += len;
176175

177176
if (conn->Pfdebug)

src/tools/RELEASE_CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ update include/version.h after release
1111
update backend/parser/scan.c and gram.c so flex/bison not necessary
1212
update pgaccess
1313
update odbc
14+
update doc/src/sgml/release.sgml
15+

0 commit comments

Comments
 (0)