From d3e2aee41487d55b8d7d40f538b84ff1db7989bc Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Fri, 17 Jul 2015 12:52:34 +1000 Subject: Check if realpath works on nonexistent files. On some platforms the native realpath doesn't work with non-existent files (this is actually specified in some versions of POSIX), however the sftp spec says its realpath with "canonicalize any given path name". On those platforms, use realpath from the compat library. In addition, when compiling with -DFORTIFY_SOURCE, glibc redefines the realpath symbol to the checked version, so redefine ours to something else so we pick up the compat version we want. bz#2428, ok djm@ --- openbsd-compat/openbsd-compat.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'openbsd-compat') 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); #endif #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) +/* + * glibc's FORTIFY_SOURCE can redefine this and prevent us picking up the + * compat version. + */ +# ifdef BROKEN_REALPATH +# define realpath(x, y) _ssh_compat_realpath(x, y) +# endif + char *realpath(const char *path, char *resolved); -#endif +#endif #ifndef HAVE_RRESVPORT_AF int rresvport_af(int *alport, sa_family_t af); -- cgit v1.2.3 From d56fd1828074a4031b18b8faa0bf949669eb18a0 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Mon, 20 Jul 2015 11:19:51 +1000 Subject: make realpath.c compile -Wsign-compare clean --- openbsd-compat/realpath.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'openbsd-compat') 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 @@ #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) +#include #include #include #include #include +#include #include #include @@ -90,7 +92,7 @@ realpath(const char *path, char resolved[PATH_MAX]) */ p = strchr(left, '/'); s = p ? p : left + left_len; - if (s - left >= sizeof(next_token)) { + if (s - left >= (ptrdiff_t)sizeof(next_token)) { errno = ENAMETOOLONG; return (NULL); } @@ -169,7 +171,8 @@ realpath(const char *path, char resolved[PATH_MAX]) */ if (p != NULL) { if (symlink[slen - 1] != '/') { - if (slen + 1 >= sizeof(symlink)) { + if (slen + 1 >= + (ptrdiff_t)sizeof(symlink)) { errno = ENAMETOOLONG; return (NULL); } -- cgit v1.2.3 From 0c30ba91f87fcda7e975e6ff8a057f624e87ea1c Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 30 Jul 2015 12:31:39 +1000 Subject: downgrade OOM adjustment logging: verbose -> debug --- openbsd-compat/port-linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbsd-compat') 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) verbose("error writing %s: %s", oom_adj_path, strerror(errno)); else - verbose("Set %s from %d to %d", + debug("Set %s from %d to %d", oom_adj_path, oom_adj_save, value); } fclose(fp); @@ -302,7 +302,7 @@ oom_adjust_restore(void) if (fprintf(fp, "%d\n", oom_adj_save) <= 0) verbose("error writing %s: %s", oom_adj_path, strerror(errno)); else - verbose("Set %s to %d", oom_adj_path, oom_adj_save); + debug("Set %s to %d", oom_adj_path, oom_adj_save); fclose(fp); return; -- cgit v1.2.3