summaryrefslogtreecommitdiff
path: root/openbsd-compat/realpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/realpath.c')
-rw-r--r--openbsd-compat/realpath.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/openbsd-compat/realpath.c b/openbsd-compat/realpath.c
index b6120d034..ba4cea938 100644
--- a/openbsd-compat/realpath.c
+++ b/openbsd-compat/realpath.c
@@ -33,11 +33,13 @@
33 33
34#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) 34#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH)
35 35
36#include <sys/types.h>
36#include <sys/param.h> 37#include <sys/param.h>
37#include <sys/stat.h> 38#include <sys/stat.h>
38 39
39#include <errno.h> 40#include <errno.h>
40#include <stdlib.h> 41#include <stdlib.h>
42#include <stddef.h>
41#include <string.h> 43#include <string.h>
42#include <unistd.h> 44#include <unistd.h>
43 45
@@ -90,7 +92,7 @@ realpath(const char *path, char resolved[PATH_MAX])
90 */ 92 */
91 p = strchr(left, '/'); 93 p = strchr(left, '/');
92 s = p ? p : left + left_len; 94 s = p ? p : left + left_len;
93 if (s - left >= sizeof(next_token)) { 95 if (s - left >= (ptrdiff_t)sizeof(next_token)) {
94 errno = ENAMETOOLONG; 96 errno = ENAMETOOLONG;
95 return (NULL); 97 return (NULL);
96 } 98 }
@@ -169,7 +171,8 @@ realpath(const char *path, char resolved[PATH_MAX])
169 */ 171 */
170 if (p != NULL) { 172 if (p != NULL) {
171 if (symlink[slen - 1] != '/') { 173 if (symlink[slen - 1] != '/') {
172 if (slen + 1 >= sizeof(symlink)) { 174 if (slen + 1 >=
175 (ptrdiff_t)sizeof(symlink)) {
173 errno = ENAMETOOLONG; 176 errno = ENAMETOOLONG;
174 return (NULL); 177 return (NULL);
175 } 178 }