summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorTom Lane2006-09-27 18:40:10 +0000
committerTom Lane2006-09-27 18:40:10 +0000
commitc92f7e258ee579abd0f95183598edf250d351b2c (patch)
tree10c6b377a74c61b71ece70cfd3cb209795bf1051 /src/port
parent996b203e621bc76985ff0156b4f2ef720944b41b (diff)
Replace strncpy with strlcpy in selected places that seem possibly relevant
to performance. (A wholesale effort to get rid of strncpy should be undertaken sometime, but not during beta.) This commit also fixes dynahash.c to correctly truncate overlength string keys for hashtables, so that its callers don't have to anymore.
Diffstat (limited to 'src/port')
-rw-r--r--src/port/path.c10
-rw-r--r--src/port/thread.c4
2 files changed, 7 insertions, 7 deletions
diff --git a/src/port/path.c b/src/port/path.c
index 4acb8046bfc..a7d5ec7c452 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.68 2006/09/22 21:39:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.69 2006/09/27 18:40:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,7 +174,7 @@ join_path_components(char *ret_path,
const char *head, const char *tail)
{
if (ret_path != head)
- StrNCpy(ret_path, head, MAXPGPATH);
+ strlcpy(ret_path, head, MAXPGPATH);
/*
* Remove any leading "." and ".." in the tail component, adjusting head
@@ -493,7 +493,7 @@ make_relative_path(char *ret_path, const char *target_path,
* Set up my_exec_path without the actual executable name, and
* canonicalize to simplify comparison to bin_path.
*/
- StrNCpy(ret_path, my_exec_path, MAXPGPATH);
+ strlcpy(ret_path, my_exec_path, MAXPGPATH);
trim_directory(ret_path); /* remove my executable name */
canonicalize_path(ret_path);
@@ -513,7 +513,7 @@ make_relative_path(char *ret_path, const char *target_path,
}
no_match:
- StrNCpy(ret_path, target_path, MAXPGPATH);
+ strlcpy(ret_path, target_path, MAXPGPATH);
canonicalize_path(ret_path);
}
@@ -625,7 +625,7 @@ get_home_path(char *ret_path)
if (pqGetpwuid(geteuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) != 0)
return false;
- StrNCpy(ret_path, pwd->pw_dir, MAXPGPATH);
+ strlcpy(ret_path, pwd->pw_dir, MAXPGPATH);
return true;
#else
char tmppath[MAX_PATH];
diff --git a/src/port/thread.c b/src/port/thread.c
index 04f42f55b2c..74e6508c36a 100644
--- a/src/port/thread.c
+++ b/src/port/thread.c
@@ -7,7 +7,7 @@
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/port/thread.c,v 1.34 2006/07/06 02:12:32 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/thread.c,v 1.35 2006/09/27 18:40:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -81,7 +81,7 @@ pqStrerror(int errnum, char *strerrbuf, size_t buflen)
#endif
#else
/* no strerror_r() available, just use strerror */
- StrNCpy(strerrbuf, strerror(errnum), buflen);
+ strlcpy(strerrbuf, strerror(errnum), buflen);
return strerrbuf;
#endif