Commit 205b5c2f authored by Tom Lane's avatar Tom Lane

A little paranoia never hurt anyone.

parent c0e9dc12
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.49 2001/10/25 05:49:51 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.50 2002/05/05 17:50:04 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -222,8 +222,10 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) ...@@ -222,8 +222,10 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
/* Found it; extract the OID and the database path. */ /* Found it; extract the OID and the database path. */
*db_id = tup.t_data->t_oid; *db_id = tup.t_data->t_oid;
pathlen = VARSIZE(&(tup_db->datpath)) - VARHDRSZ; pathlen = VARSIZE(&(tup_db->datpath)) - VARHDRSZ;
if (pathlen < 0)
pathlen = 0; /* pure paranoia */
if (pathlen >= MAXPGPATH) if (pathlen >= MAXPGPATH)
pathlen = MAXPGPATH - 1; /* pure paranoia */ pathlen = MAXPGPATH - 1; /* more paranoia */
strncpy(path, VARDATA(&(tup_db->datpath)), pathlen); strncpy(path, VARDATA(&(tup_db->datpath)), pathlen);
path[pathlen] = '\0'; path[pathlen] = '\0';
goto done; goto done;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment