diff options
author | Peter Eisentraut | 2020-08-10 16:51:31 +0000 |
---|---|---|
committer | Peter Eisentraut | 2020-08-10 21:20:37 +0000 |
commit | 1784f278a63866cc144fcd0a2127cadba6a2b7f8 (patch) | |
tree | ce0f644de0d3a89fc8b49ff67be8428731cb041b /src/common/exec.c | |
parent | cec57b1a0fbcd3833086ba686897c5883e0a2afc (diff) |
Replace remaining StrNCpy() by strlcpy()
They are equivalent, except that StrNCpy() zero-fills the entire
destination buffer instead of providing just one trailing zero. For
all but a tiny number of callers, that's just overhead rather than
being desirable.
Remove StrNCpy() as it is now unused.
In some cases, namestrcpy() is the more appropriate function to use.
While we're here, simplify the API of namestrcpy(): Remove the return
value, don't check for NULL input. Nothing was using that anyway.
Also, remove a few unused name-related functions.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/44f5e198-36f6-6cdb-7fa9-60e34784daae%402ndquadrant.com
Diffstat (limited to 'src/common/exec.c')
-rw-r--r-- | src/common/exec.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/exec.c b/src/common/exec.c index f39b0a294bf..78bb486f999 100644 --- a/src/common/exec.c +++ b/src/common/exec.c @@ -144,7 +144,7 @@ find_my_exec(const char *argv0, char *retpath) if (first_dir_separator(argv0) != NULL) { if (is_absolute_path(argv0)) - StrNCpy(retpath, argv0, MAXPGPATH); + strlcpy(retpath, argv0, MAXPGPATH); else join_path_components(retpath, cwd, argv0); canonicalize_path(retpath); @@ -184,7 +184,7 @@ find_my_exec(const char *argv0, char *retpath) if (!endp) endp = startp + strlen(startp); /* point to end */ - StrNCpy(test_path, startp, Min(endp - startp + 1, MAXPGPATH)); + strlcpy(test_path, startp, Min(endp - startp + 1, MAXPGPATH)); if (is_absolute_path(test_path)) join_path_components(retpath, test_path, argv0); |