mirror of git://anongit.mindrot.org/openssh.git
Check for and work around buggy fflush(NULL).
Some really old platforms (eg SunOS4) segfault on fflush(NULL) so check for and work around. With klausz at haus-gisela.de.
This commit is contained in:
parent
71e48bc794
commit
58fd4c5c01
10
configure.ac
10
configure.ac
|
@ -2059,6 +2059,16 @@ AC_CHECK_FUNCS([realpath], [
|
|||
)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([for working fflush(NULL)])
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(NULL); exit(0);]])],
|
||||
AC_MSG_RESULT([yes]),
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_DEFINE([FFLUSH_NULL_BUG], [1],
|
||||
[define if fflush(NULL) does not work])],
|
||||
AC_MSG_WARN([cross compiling: assuming working])
|
||||
)
|
||||
|
||||
dnl Checks for time functions
|
||||
AC_CHECK_FUNCS([gettimeofday time])
|
||||
dnl Checks for utmp functions
|
||||
|
|
|
@ -308,3 +308,19 @@ getsid(pid_t pid)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef FFLUSH_NULL_BUG
|
||||
#undef fflush
|
||||
int _ssh_compat_fflush(FILE *f)
|
||||
{
|
||||
int r1, r2, r3;
|
||||
|
||||
if (f == NULL) {
|
||||
r2 = fflush(stdout);
|
||||
r3 = fflush(stderr);
|
||||
if (r1 == -1 || r2 == -1 || r3 == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
return fflush(f);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -153,4 +153,8 @@ pid_t getsid(pid_t);
|
|||
int flock(int, int);
|
||||
#endif
|
||||
|
||||
#ifdef FFLUSH_NULL_BUG
|
||||
# define fflush(x) (_ssh_compat_fflush(x))
|
||||
#endif
|
||||
|
||||
#endif /* _BSD_MISC_H */
|
||||
|
|
Loading…
Reference in New Issue