From e69967f5348cec651f8806d25d2c59ac8ed8c2a2 Mon Sep 17 00:00:00 2001 From: nectar Date: Tue, 29 Apr 2003 21:13:50 +0000 Subject: `Hide' strlcpy and strlcat (using the namespace.h / __weak_reference technique) so that we don't wind up calling into an application's version if the application defines them. Inspired by: qpopper's interfering and buggy version of strlcpy --- lib/libc/stdlib/realpath.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/libc/stdlib/realpath.c') diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index c269471..93a9856 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -67,14 +67,14 @@ realpath(const char *path, char resolved[PATH_MAX]) if (path[1] == '\0') return (resolved); resolved_len = 1; - left_len = strlcpy(left, path + 1, sizeof(left)); + left_len = _strlcpy(left, path + 1, sizeof(left)); } else { if (getcwd(resolved, PATH_MAX) == NULL) { - strlcpy(resolved, ".", PATH_MAX); + _strlcpy(resolved, ".", PATH_MAX); return (NULL); } resolved_len = strlen(resolved); - left_len = strlcpy(left, path, sizeof(left)); + left_len = _strlcpy(left, path, sizeof(left)); } if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) { errno = ENAMETOOLONG; @@ -131,7 +131,7 @@ realpath(const char *path, char resolved[PATH_MAX]) * lstat() fails we still can return successfully if * there are no more path components left. */ - resolved_len = strlcat(resolved, next_token, PATH_MAX); + resolved_len = _strlcat(resolved, next_token, PATH_MAX); if (resolved_len >= PATH_MAX) { errno = ENAMETOOLONG; return (NULL); @@ -177,13 +177,13 @@ realpath(const char *path, char resolved[PATH_MAX]) symlink[slen] = '/'; symlink[slen + 1] = 0; } - left_len = strlcat(symlink, left, sizeof(left)); + left_len = _strlcat(symlink, left, sizeof(left)); if (left_len >= sizeof(left)) { errno = ENAMETOOLONG; return (NULL); } } - left_len = strlcpy(left, symlink, sizeof(left)); + left_len = _strlcpy(left, symlink, sizeof(left)); } } -- cgit v1.1