From c92f7e258ee579abd0f95183598edf250d351b2c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 27 Sep 2006 18:40:10 +0000 Subject: 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. --- src/port/path.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/port/path.c') diff --git a/src/port/path.c b/src/port/path.c index 4acb8046bf..a7d5ec7c45 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]; -- cgit v1.2.1