diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 37952be212..64b585af9a 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.6 1997/03/18 21:29:21 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.7 1997/04/17 20:39:31 scrappy Exp $ * * NOTES * This should be moved to a more appropriate place. It is here @@ -249,16 +249,19 @@ lo_import(text *filename) int nbytes, tmp; #define BUFSIZE 1024 char buf[BUFSIZE]; + char fnamebuf[8192]; LargeObjectDesc *lobj; Oid lobjOid; /* * open the file to be read in */ - fd = open(VARDATA(filename), O_RDONLY, 0666); + strncpy(fnamebuf, VARDATA(filename), VARSIZE(filename)); + fnamebuf[VARSIZE(filename)] = '\0'; + fd = open(fnamebuf, O_RDONLY, 0666); if (fd < 0) { /* error */ elog(WARN, "lo_import: can't open unix file\"%s\"\n", - VARDATA(filename)); + fnamebuf); } /* @@ -267,7 +270,7 @@ lo_import(text *filename) lobj = inv_create(INV_READ|INV_WRITE); if (lobj == NULL) { elog(WARN, "lo_import: can't create inv object for \"%s\"", - VARDATA(filename)); + fnamebuf); } /* @@ -283,7 +286,7 @@ lo_import(text *filename) tmp = inv_write(lobj, buf, nbytes); if (tmp < nbytes) { elog(WARN, "lo_import: error while reading \"%s\"", - VARDATA(filename)); + fnamebuf); } } @@ -304,6 +307,7 @@ lo_export(Oid lobjId, text *filename) int nbytes, tmp; #define BUFSIZE 1024 char buf[BUFSIZE]; + char fnamebuf[8192]; LargeObjectDesc *lobj; mode_t oumask; @@ -320,11 +324,13 @@ lo_export(Oid lobjId, text *filename) * open the file to be written to */ oumask = umask((mode_t) 0); - fd = open(VARDATA(filename), O_CREAT|O_WRONLY, 0666); + strncpy(fnamebuf, VARDATA(filename), VARSIZE(filename)); + fnamebuf[VARSIZE(filename)] = '\0'; + fd = open(fnamebuf, O_CREAT|O_WRONLY, 0666); (void) umask(oumask); if (fd < 0) { /* error */ elog(WARN, "lo_export: can't open unix file\"%s\"", - VARDATA(filename)); + fnamebuf); } /* @@ -334,7 +340,7 @@ lo_export(Oid lobjId, text *filename) tmp = write(fd, buf, nbytes); if (tmp < nbytes) { elog(WARN, "lo_export: error while writing \"%s\"", - VARDATA(filename)); + fnamebuf); } } diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index d1ebdb62c1..5fce9f2757 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.30 1997/04/16 06:29:19 vadim Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.31 1997/04/17 20:39:23 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -196,6 +196,7 @@ PQconnectdb(const char *conninfo) * Setup the conn structure * ---------- */ + conn->lobjfuncs = (PGlobjfuncs *) NULL; conn->Pfout = NULL; conn->Pfin = NULL; conn->Pfdebug = NULL;