summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/openbsd-compat.h10
-rw-r--r--openbsd-compat/port-linux.c4
-rw-r--r--openbsd-compat/realpath.c7
3 files changed, 16 insertions, 5 deletions
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index cb59ccd57..1ff7114ef 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -70,8 +70,16 @@ void *reallocarray(void *, size_t, size_t);
70#endif 70#endif
71 71
72#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) 72#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH)
73/*
74 * glibc's FORTIFY_SOURCE can redefine this and prevent us picking up the
75 * compat version.
76 */
77# ifdef BROKEN_REALPATH
78# define realpath(x, y) _ssh_compat_realpath(x, y)
79# endif
80
73char *realpath(const char *path, char *resolved); 81char *realpath(const char *path, char *resolved);
74#endif 82#endif
75 83
76#ifndef HAVE_RRESVPORT_AF 84#ifndef HAVE_RRESVPORT_AF
77int rresvport_af(int *alport, sa_family_t af); 85int rresvport_af(int *alport, sa_family_t af);
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c
index 4637a7a3e..f36999d7a 100644
--- a/openbsd-compat/port-linux.c
+++ b/openbsd-compat/port-linux.c
@@ -278,7 +278,7 @@ oom_adjust_setup(void)
278 verbose("error writing %s: %s", 278 verbose("error writing %s: %s",
279 oom_adj_path, strerror(errno)); 279 oom_adj_path, strerror(errno));
280 else 280 else
281 verbose("Set %s from %d to %d", 281 debug("Set %s from %d to %d",
282 oom_adj_path, oom_adj_save, value); 282 oom_adj_path, oom_adj_save, value);
283 } 283 }
284 fclose(fp); 284 fclose(fp);
@@ -302,7 +302,7 @@ oom_adjust_restore(void)
302 if (fprintf(fp, "%d\n", oom_adj_save) <= 0) 302 if (fprintf(fp, "%d\n", oom_adj_save) <= 0)
303 verbose("error writing %s: %s", oom_adj_path, strerror(errno)); 303 verbose("error writing %s: %s", oom_adj_path, strerror(errno));
304 else 304 else
305 verbose("Set %s to %d", oom_adj_path, oom_adj_save); 305 debug("Set %s to %d", oom_adj_path, oom_adj_save);
306 306
307 fclose(fp); 307 fclose(fp);
308 return; 308 return;
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 }