StrNCpy -> strlcpy (not complete)

This commit is contained in:
Peter Eisentraut 2007-02-10 14:58:55 +00:00
parent 1a1474b4c0
commit 4ab8fcba8a
16 changed files with 58 additions and 58 deletions

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.229 2007/01/22 01:35:19 tgl Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.230 2007/02/10 14:58:54 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -277,7 +277,7 @@ BootstrapMain(int argc, char *argv[])
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV); SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
break; break;
case 'r': case 'r':
StrNCpy(OutputFileName, optarg, MAXPGPATH); strlcpy(OutputFileName, optarg, MAXPGPATH);
break; break;
case 'x': case 'x':
xlogop = atoi(optarg); xlogop = atoi(optarg);

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.72 2007/01/05 22:19:29 momjian Exp $ * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.73 2007/02/10 14:58:54 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -110,7 +110,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
{ {
char salt[3]; char salt[3];
StrNCpy(salt, port->cryptSalt, 3); strlcpy(salt, port->cryptSalt, sizeof(salt));
crypt_pwd = crypt(shadow_pass, salt); crypt_pwd = crypt(shadow_pass, salt);
break; break;
} }

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.159 2007/02/08 04:52:18 momjian Exp $ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.160 2007/02/10 14:58:54 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1463,7 +1463,7 @@ ident_unix(int sock, char *ident_user)
return false; return false;
} }
StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1); strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
return true; return true;
#elif defined(SO_PEERCRED) #elif defined(SO_PEERCRED)
@ -1493,7 +1493,7 @@ ident_unix(int sock, char *ident_user)
return false; return false;
} }
StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1); strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
return true; return true;
#elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) #elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))
@ -1562,7 +1562,7 @@ ident_unix(int sock, char *ident_user)
return false; return false;
} }
StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1); strlcpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
return true; return true;
#else #else

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.39 2007/01/05 22:19:29 momjian Exp $ * $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.40 2007/02/10 14:58:54 petere Exp $
* *
* This file and the IPV6 implementation were initially provided by * This file and the IPV6 implementation were initially provided by
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design * Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@ -175,9 +175,9 @@ pg_getnameinfo_all(const struct sockaddr_storage * addr, int salen,
if (rc != 0) if (rc != 0)
{ {
if (node) if (node)
StrNCpy(node, "???", nodelen); strlcpy(node, "???", nodelen);
if (service) if (service)
StrNCpy(service, "???", servicelen); strlcpy(service, "???", servicelen);
} }
return rc; return rc;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.83 2007/01/20 20:45:38 tgl Exp $ * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.84 2007/02/10 14:58:54 petere Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
@ -574,28 +574,28 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
RangeTblEntry *rte; RangeTblEntry *rte;
rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable); rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable);
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN); strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
} }
else if (IsA(p, IndexScan)) else if (IsA(p, IndexScan))
{ {
RangeTblEntry *rte; RangeTblEntry *rte;
rte = rt_fetch(((IndexScan *) p)->scan.scanrelid, parsetree->rtable); rte = rt_fetch(((IndexScan *) p)->scan.scanrelid, parsetree->rtable);
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN); strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
} }
else if (IsA(p, FunctionScan)) else if (IsA(p, FunctionScan))
{ {
RangeTblEntry *rte; RangeTblEntry *rte;
rte = rt_fetch(((FunctionScan *) p)->scan.scanrelid, parsetree->rtable); rte = rt_fetch(((FunctionScan *) p)->scan.scanrelid, parsetree->rtable);
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN); strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
} }
else if (IsA(p, ValuesScan)) else if (IsA(p, ValuesScan))
{ {
RangeTblEntry *rte; RangeTblEntry *rte;
rte = rt_fetch(((ValuesScan *) p)->scan.scanrelid, parsetree->rtable); rte = rt_fetch(((ValuesScan *) p)->scan.scanrelid, parsetree->rtable);
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN); strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
} }
else else
extraInfo[0] = '\0'; extraInfo[0] = '\0';

View File

@ -19,7 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.28 2007/01/05 22:19:36 momjian Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.29 2007/02/10 14:58:54 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -429,14 +429,14 @@ pgarch_archiveXlog(char *xlog)
case 'p': case 'p':
/* %p: relative path of source file */ /* %p: relative path of source file */
sp++; sp++;
StrNCpy(dp, pathname, endp - dp); strlcpy(dp, pathname, endp - dp);
make_native_path(dp); make_native_path(dp);
dp += strlen(dp); dp += strlen(dp);
break; break;
case 'f': case 'f':
/* %f: filename of source file */ /* %f: filename of source file */
sp++; sp++;
StrNCpy(dp, xlog, endp - dp); strlcpy(dp, xlog, endp - dp);
dp += strlen(dp); dp += strlen(dp);
break; break;
case '%': case '%':

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.518 2007/02/08 15:46:04 momjian Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.519 2007/02/10 14:58:54 petere Exp $
* *
* NOTES * NOTES
* *
@ -3828,7 +3828,7 @@ save_backend_variables(BackendParameters * param, Port *port,
memcpy(&param->port, port, sizeof(Port)); memcpy(&param->port, port, sizeof(Port));
write_inheritable_socket(&param->portsocket, port->sock, childPid); write_inheritable_socket(&param->portsocket, port->sock, childPid);
StrNCpy(param->DataDir, DataDir, MAXPGPATH); strlcpy(param->DataDir, DataDir, MAXPGPATH);
memcpy(&param->ListenSocket, &ListenSocket, sizeof(ListenSocket)); memcpy(&param->ListenSocket, &ListenSocket, sizeof(ListenSocket));
@ -3859,14 +3859,14 @@ save_backend_variables(BackendParameters * param, Port *port,
memcpy(&param->syslogPipe, &syslogPipe, sizeof(syslogPipe)); memcpy(&param->syslogPipe, &syslogPipe, sizeof(syslogPipe));
StrNCpy(param->my_exec_path, my_exec_path, MAXPGPATH); strlcpy(param->my_exec_path, my_exec_path, MAXPGPATH);
StrNCpy(param->pkglib_path, pkglib_path, MAXPGPATH); strlcpy(param->pkglib_path, pkglib_path, MAXPGPATH);
StrNCpy(param->ExtraOptions, ExtraOptions, MAXPGPATH); strlcpy(param->ExtraOptions, ExtraOptions, MAXPGPATH);
StrNCpy(param->lc_collate, setlocale(LC_COLLATE, NULL), LOCALE_NAME_BUFLEN); strlcpy(param->lc_collate, setlocale(LC_COLLATE, NULL), LOCALE_NAME_BUFLEN);
StrNCpy(param->lc_ctype, setlocale(LC_CTYPE, NULL), LOCALE_NAME_BUFLEN); strlcpy(param->lc_ctype, setlocale(LC_CTYPE, NULL), LOCALE_NAME_BUFLEN);
return true; return true;
} }
@ -4060,11 +4060,11 @@ restore_backend_variables(BackendParameters * param, Port *port)
memcpy(&syslogPipe, &param->syslogPipe, sizeof(syslogPipe)); memcpy(&syslogPipe, &param->syslogPipe, sizeof(syslogPipe));
StrNCpy(my_exec_path, param->my_exec_path, MAXPGPATH); strlcpy(my_exec_path, param->my_exec_path, MAXPGPATH);
StrNCpy(pkglib_path, param->pkglib_path, MAXPGPATH); strlcpy(pkglib_path, param->pkglib_path, MAXPGPATH);
StrNCpy(ExtraOptions, param->ExtraOptions, MAXPGPATH); strlcpy(ExtraOptions, param->ExtraOptions, MAXPGPATH);
setlocale(LC_COLLATE, param->lc_collate); setlocale(LC_COLLATE, param->lc_collate);
setlocale(LC_CTYPE, param->lc_ctype); setlocale(LC_CTYPE, param->lc_ctype);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.521 2007/01/05 22:19:39 momjian Exp $ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.522 2007/02/10 14:58:55 petere Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
@ -2846,7 +2846,7 @@ PostgresMain(int argc, char *argv[], const char *username)
case 'r': case 'r':
/* send output (stdout and stderr) to the given file */ /* send output (stdout and stderr) to the given file */
if (secure) if (secure)
StrNCpy(OutputFileName, optarg, MAXPGPATH); strlcpy(OutputFileName, optarg, MAXPGPATH);
break; break;
case 'S': case 'S':

View File

@ -4,7 +4,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.46 2007/01/05 22:19:46 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.47 2007/02/10 14:58:55 petere Exp $
*/ */
%{ %{
@ -218,7 +218,7 @@ ParseConfigFile(const char *config_file, const char *calling_file,
if (!is_absolute_path(config_file)) if (!is_absolute_path(config_file))
{ {
Assert(calling_file != NULL); Assert(calling_file != NULL);
StrNCpy(abs_path, calling_file, MAXPGPATH); strlcpy(abs_path, calling_file, sizeof(abs_path));
get_parent_directory(abs_path); get_parent_directory(abs_path);
join_path_components(abs_path, abs_path, config_file); join_path_components(abs_path, abs_path, config_file);
canonicalize_path(abs_path); canonicalize_path(abs_path);

View File

@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * Portions taken from FreeBSD.
* *
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.131 2007/02/01 19:10:28 momjian Exp $ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.132 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -2706,7 +2706,7 @@ main(int argc, char *argv[])
char full_path[MAXPGPATH]; char full_path[MAXPGPATH];
if (find_my_exec(argv[0], full_path) < 0) if (find_my_exec(argv[0], full_path) < 0)
StrNCpy(full_path, progname, MAXPGPATH); strlcpy(full_path, progname, sizeof(full_path));
if (ret == -1) if (ret == -1)
fprintf(stderr, fprintf(stderr,

View File

@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.77 2007/02/01 19:10:28 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.78 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -416,7 +416,7 @@ test_postmaster_connection(void)
/* advance past whitespace/quoting */ /* advance past whitespace/quoting */
while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') while (isspace((unsigned char) *p) || *p == '\'' || *p == '"')
p++; p++;
StrNCpy(portstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1, strlcpy(portstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1,
sizeof(portstr))); sizeof(portstr)));
/* keep looking, maybe there is another -p */ /* keep looking, maybe there is another -p */
} }
@ -449,7 +449,7 @@ test_postmaster_connection(void)
p++; p++;
while (isspace((unsigned char) *p)) while (isspace((unsigned char) *p))
p++; p++;
StrNCpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, strlcpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1,
sizeof(portstr))); sizeof(portstr)));
/* keep looking, maybe there is another */ /* keep looking, maybe there is another */
} }
@ -458,7 +458,7 @@ test_postmaster_connection(void)
/* environment */ /* environment */
if (!*portstr && getenv("PGPORT") != NULL) if (!*portstr && getenv("PGPORT") != NULL)
StrNCpy(portstr, getenv("PGPORT"), sizeof(portstr)); strlcpy(portstr, getenv("PGPORT"), sizeof(portstr));
/* default */ /* default */
if (!*portstr) if (!*portstr)
@ -594,7 +594,7 @@ do_start(void)
char full_path[MAXPGPATH]; char full_path[MAXPGPATH];
if (find_my_exec(argv0, full_path) < 0) if (find_my_exec(argv0, full_path) < 0)
StrNCpy(full_path, progname, MAXPGPATH); strlcpy(full_path, progname, sizeof(full_path));
if (ret == -1) if (ret == -1)
write_stderr(_("The program \"postgres\" is needed by %s " write_stderr(_("The program \"postgres\" is needed by %s "

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* *
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.89 2007/01/25 03:30:43 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.90 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -150,7 +150,7 @@ main(int argc, char *argv[])
char full_path[MAXPGPATH]; char full_path[MAXPGPATH];
if (find_my_exec(argv[0], full_path) < 0) if (find_my_exec(argv[0], full_path) < 0)
StrNCpy(full_path, progname, MAXPGPATH); strlcpy(full_path, progname, sizeof(full_path));
if (ret == -1) if (ret == -1)
fprintf(stderr, fprintf(stderr,

View File

@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.56 2007/02/01 19:10:29 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.57 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -498,14 +498,14 @@ GuessControlValues(void)
fprintf(stderr, _("%s: invalid LC_COLLATE setting\n"), progname); fprintf(stderr, _("%s: invalid LC_COLLATE setting\n"), progname);
exit(1); exit(1);
} }
StrNCpy(ControlFile.lc_collate, localeptr, LOCALE_NAME_BUFLEN); strlcpy(ControlFile.lc_collate, localeptr, sizeof(ControlFile.lc_collate));
localeptr = setlocale(LC_CTYPE, ""); localeptr = setlocale(LC_CTYPE, "");
if (!localeptr) if (!localeptr)
{ {
fprintf(stderr, _("%s: invalid LC_CTYPE setting\n"), progname); fprintf(stderr, _("%s: invalid LC_CTYPE setting\n"), progname);
exit(1); exit(1);
} }
StrNCpy(ControlFile.lc_ctype, localeptr, LOCALE_NAME_BUFLEN); strlcpy(ControlFile.lc_ctype, localeptr, sizeof(ControlFile.lc_ctype));
/* /*
* XXX eventually, should try to grovel through old XLOG to develop more * XXX eventually, should try to grovel through old XLOG to develop more

View File

@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.122 2007/01/05 22:20:00 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.123 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -418,7 +418,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
{ {
char salt[3]; char salt[3];
StrNCpy(salt, conn->cryptSalt, 3); strlcpy(salt, conn->cryptSalt, sizeof(salt));
crypt_pwd = crypt(password, salt); crypt_pwd = crypt(password, salt);
break; break;
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.342 2007/02/08 11:10:27 petere Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.343 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -2208,7 +2208,7 @@ internal_cancel(SockAddr *raddr, int be_pid, int be_key,
*/ */
if ((tmpsock = socket(raddr->addr.ss_family, SOCK_STREAM, 0)) < 0) if ((tmpsock = socket(raddr->addr.ss_family, SOCK_STREAM, 0)) < 0)
{ {
StrNCpy(errbuf, "PQcancel() -- socket() failed: ", errbufsize); strlcpy(errbuf, "PQcancel() -- socket() failed: ", errbufsize);
goto cancel_errReturn; goto cancel_errReturn;
} }
retry3: retry3:
@ -2218,7 +2218,7 @@ retry3:
if (SOCK_ERRNO == EINTR) if (SOCK_ERRNO == EINTR)
/* Interrupted system call - we'll just try again */ /* Interrupted system call - we'll just try again */
goto retry3; goto retry3;
StrNCpy(errbuf, "PQcancel() -- connect() failed: ", errbufsize); strlcpy(errbuf, "PQcancel() -- connect() failed: ", errbufsize);
goto cancel_errReturn; goto cancel_errReturn;
} }
@ -2239,7 +2239,7 @@ retry4:
if (SOCK_ERRNO == EINTR) if (SOCK_ERRNO == EINTR)
/* Interrupted system call - we'll just try again */ /* Interrupted system call - we'll just try again */
goto retry4; goto retry4;
StrNCpy(errbuf, "PQcancel() -- send() failed: ", errbufsize); strlcpy(errbuf, "PQcancel() -- send() failed: ", errbufsize);
goto cancel_errReturn; goto cancel_errReturn;
} }
@ -2297,7 +2297,7 @@ PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
{ {
if (!cancel) if (!cancel)
{ {
StrNCpy(errbuf, "PQcancel() -- no cancel object supplied", errbufsize); strlcpy(errbuf, "PQcancel() -- no cancel object supplied", errbufsize);
return FALSE; return FALSE;
} }
@ -2328,7 +2328,7 @@ PQrequestCancel(PGconn *conn)
if (conn->sock < 0) if (conn->sock < 0)
{ {
StrNCpy(conn->errorMessage.data, strlcpy(conn->errorMessage.data,
"PQrequestCancel() -- connection is not open\n", "PQrequestCancel() -- connection is not open\n",
conn->errorMessage.maxlen); conn->errorMessage.maxlen);
conn->errorMessage.len = strlen(conn->errorMessage.data); conn->errorMessage.len = strlen(conn->errorMessage.data);
@ -3609,7 +3609,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
if ((passfile_env = getenv("PGPASSFILE")) != NULL) if ((passfile_env = getenv("PGPASSFILE")) != NULL)
/* use the literal path from the environment, if set */ /* use the literal path from the environment, if set */
StrNCpy(pgpassfile, passfile_env, MAXPGPATH); strlcpy(pgpassfile, passfile_env, sizeof(pgpassfile));
else else
{ {
char homedir[MAXPGPATH]; char homedir[MAXPGPATH];
@ -3700,7 +3700,7 @@ pqGetHomeDirectory(char *buf, int bufsize)
if (pqGetpwuid(geteuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) != 0) if (pqGetpwuid(geteuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) != 0)
return false; return false;
StrNCpy(buf, pwd->pw_dir, bufsize); strlcpy(buf, pwd->pw_dir, bufsize);
return true; return true;
#else #else
char tmppath[MAX_PATH]; char tmppath[MAX_PATH];

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.49 2007/01/05 22:20:04 momjian Exp $ * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.50 2007/02/10 14:58:55 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -566,7 +566,7 @@ scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry * tt,
if (score > *bestscore) if (score > *bestscore)
{ {
*bestscore = score; *bestscore = score;
StrNCpy(bestzonename, tzdirsub, TZ_STRLEN_MAX + 1); strlcpy(bestzonename, tzdirsub, TZ_STRLEN_MAX + 1);
} }
else if (score == *bestscore) else if (score == *bestscore)
{ {
@ -574,7 +574,7 @@ scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry * tt,
if (strlen(tzdirsub) < strlen(bestzonename) || if (strlen(tzdirsub) < strlen(bestzonename) ||
(strlen(tzdirsub) == strlen(bestzonename) && (strlen(tzdirsub) == strlen(bestzonename) &&
strcmp(tzdirsub, bestzonename) < 0)) strcmp(tzdirsub, bestzonename) < 0))
StrNCpy(bestzonename, tzdirsub, TZ_STRLEN_MAX + 1); strlcpy(bestzonename, tzdirsub, TZ_STRLEN_MAX + 1);
} }
} }