1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Standardize on MAXPGPATH as the size of a file pathname buffer,

eliminating some wildly inconsistent coding in various parts of the
system.  I set MAXPGPATH = 1024 in config.h.in.  If anyone is really
convinced that there ought to be a configure-time test to set the
value, go right ahead ... but I think it's a waste of time.
This commit is contained in:
Tom Lane
1999-10-25 03:08:03 +00:00
parent 8a17ed6335
commit 51f62d505e
22 changed files with 183 additions and 193 deletions

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.45 1999/10/22 23:14:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.46 1999/10/25 03:07:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,11 +22,6 @@
#include "postgres.h"
#ifndef PATH_MAX
#include <sys/param.h>
#define PATH_MAX MAXPATHLEN
#endif
#include "miscadmin.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
@@ -527,7 +522,7 @@ cppline {space}*#.*(\\{space}*\n)*\n*
<incl>[^ \t\n]+ { /* got the include file name */
struct _yy_buffer *yb;
struct _include_path *ip;
char inc_file[PATH_MAX];
char inc_file[MAXPGPATH];
yb = mm_alloc(sizeof(struct _yy_buffer));
@@ -544,7 +539,7 @@ cppline {space}*#.*(\\{space}*\n)*\n*
yyin = NULL;
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
{
if (strlen(ip->path) + strlen(yytext) + 3 > PATH_MAX)
if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
{
fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
continue;

View File

@@ -9,7 +9,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.33 1999/08/31 01:37:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.34 1999/10/25 03:08:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -127,7 +127,7 @@ pg_krb4_init()
*/
if (realm = getenv("PGREALM"))
{
char tktbuf[MAXPATHLEN];
char tktbuf[MAXPGPATH];
(void) sprintf(tktbuf, "%s@%s", tkt_string(), realm);
krb_set_tkt_string(tktbuf);
@@ -272,7 +272,7 @@ pg_krb5_init(void)
krb5_error_code code;
char *realm,
*defname;
char tktbuf[MAXPATHLEN];
char tktbuf[MAXPGPATH];
static krb5_ccache ccache = (krb5_ccache) NULL;
if (ccache)

View File

@@ -36,11 +36,6 @@
#define FALSE ((BOOL)0)
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#else
#define MAXPATHLEN 255
#endif
DWORD
GetPrivateProfileString(char *theSection, // section name
@@ -50,7 +45,7 @@ GetPrivateProfileString(char *theSection, // section name
size_t theReturnBufferLength, // byte length of return buffer
char *theIniFileName) // pathname of ini file to search
{
char buf[MAXPATHLEN+1];
char buf[MAXPGPATH];
char* ptr = 0;
FILE* aFile = 0;
size_t aLength;
@@ -70,8 +65,8 @@ GetPrivateProfileString(char *theSection, // section name
if( ptr == NULL)
{
if( MAXPATHLEN < j )
theIniFileName[MAXPATHLEN] = '\0';
if( MAXPGPATH-1 < j )
theIniFileName[MAXPGPATH-1] = '\0';
sprintf(buf,"%s",theIniFileName);
}
@@ -84,12 +79,12 @@ GetPrivateProfileString(char *theSection, // section name
* the file won't be found and thus the default value will be
* returned.
*/
if( MAXPATHLEN < strlen(ptr) + j )
if( MAXPGPATH-1 < strlen(ptr) + j )
{
if( MAXPATHLEN < strlen(ptr) )
ptr[MAXPATHLEN] = '\0';
if( MAXPGPATH-1 < strlen(ptr) )
ptr[MAXPGPATH-1] = '\0';
else
theIniFileName[MAXPATHLEN-strlen(ptr)] = '\0';
theIniFileName[MAXPGPATH-1-strlen(ptr)] = '\0';
}
sprintf( buf, "%s/%s",ptr,theIniFileName );
@@ -323,7 +318,7 @@ WritePrivateProfileString(char *theSection, // section name
char *theBuffer, // input buffer
char *theIniFileName) // pathname of ini file to write
{
char buf[MAXPATHLEN+1];
char buf[MAXPGPATH];
char* ptr = 0;
FILE* aFile = 0;
size_t aLength;
@@ -349,8 +344,8 @@ WritePrivateProfileString(char *theSection, // section name
if( ptr == NULL)
{
if( MAXPATHLEN < j )
theIniFileName[MAXPATHLEN] = '\0';
if( MAXPGPATH-1 < j )
theIniFileName[MAXPGPATH-1] = '\0';
sprintf(buf,"%s",theIniFileName);
}
@@ -363,12 +358,12 @@ WritePrivateProfileString(char *theSection, // section name
// the file won't be found and thus the default value will be
// returned.
//
if( MAXPATHLEN < strlen(ptr) + j )
if( MAXPGPATH-1 < strlen(ptr) + j )
{
if( MAXPATHLEN < strlen(ptr) )
ptr[MAXPATHLEN] = '\0';
if( MAXPGPATH-1 < strlen(ptr) )
ptr[MAXPGPATH-1] = '\0';
else
theIniFileName[MAXPATHLEN-strlen(ptr)] = '\0';
theIniFileName[MAXPGPATH-1-strlen(ptr)] = '\0';
}
sprintf( buf, "%s/%s",ptr,theIniFileName );

View File

@@ -32,7 +32,6 @@ extern GLOBAL_VALUES globals;
// Constants ---------------------------------------------------------------
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAXPATHLEN (255+1) // Max path length
#define MAXKEYLEN (15+1) // Max keyword length
#define MAXDESC (255+1) // Max description length
#define MAXDSNAME (32+1) // Max data source name length
@@ -323,7 +322,7 @@ LPCSTR lpsz;
LPCSTR lpszStart;
char aszKey[MAXKEYLEN];
int cbKey;
char value[MAXPATHLEN];
char value[MAXPGPATH];
memset(&lpsetupdlg->ci, 0, sizeof(ConnInfo));
@@ -352,7 +351,7 @@ char value[MAXPATHLEN];
// lpsetupdlg->aAttr[iElement].fSupplied = TRUE;
_fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPATHLEN));
_fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPGPATH));
mylog("aszKey='%s', value='%s'\n", aszKey, value);
@@ -384,8 +383,8 @@ LPCSTR lpszDSN; // Pointer to da
{
if (hwndParent)
{
char szBuf[MAXPATHLEN];
char szMsg[MAXPATHLEN];
char szBuf[MAXPGPATH];
char szMsg[MAXPGPATH];
LoadString(s_hModule, IDS_BADDSN, szBuf, sizeof(szBuf));
wsprintf(szMsg, szBuf, lpszDSN);