summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-07-01 16:52:55 +1000
committerDamien Miller <djm@mindrot.org>2000-07-01 16:52:55 +1000
commitcb170cb225e62f6deda4911f0fbab2d6cd6b8062 (patch)
tree003880eaf4ddfda40e01a1baee5f2d85f69e2704
parent28adeef966d890b5831d831b1f0e1100c9db5b0a (diff)
- (djm) Added check for broken snprintf() functions which do not correctly
terminate output string and attempt to use replacement.
-rw-r--r--ChangeLog2
-rw-r--r--acconfig.h3
-rw-r--r--bsd-snprintf.c12
-rw-r--r--configure.in17
4 files changed, 28 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1bbdff7b6..b7c566bbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
4 - (djm) Replace "/bin/sh" with _PATH_BSHELL. Report from Corinna Vinschen 4 - (djm) Replace "/bin/sh" with _PATH_BSHELL. Report from Corinna Vinschen
5 <vinschen@cygnus.com> 5 <vinschen@cygnus.com>
6 - (djm) Replace "/usr/bin/login" with LOGIN_PROGRAM 6 - (djm) Replace "/usr/bin/login" with LOGIN_PROGRAM
7 - (djm) Added check for broken snprintf() functions which do not correctly
8 terminate output string and attempt to use replacement.
7 9
820000628 1020000628
9 - (djm) Fixes to lastlog code for Irix 11 - (djm) Fixes to lastlog code for Irix
diff --git a/acconfig.h b/acconfig.h
index f10370df4..b011d0421 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -6,6 +6,9 @@
6 6
7@TOP@ 7@TOP@
8 8
9/* Define if your snprintf is busted */
10#undef BROKEN_SNPRINTF
11
9/* Define if you are on NeXT */ 12/* Define if you are on NeXT */
10#undef HAVE_NEXT 13#undef HAVE_NEXT
11 14
diff --git a/bsd-snprintf.c b/bsd-snprintf.c
index c31fc38d6..ff26a1048 100644
--- a/bsd-snprintf.c
+++ b/bsd-snprintf.c
@@ -26,7 +26,7 @@
26 26
27#include "config.h" 27#include "config.h"
28 28
29#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) 29#if defined(BROKEN_SNPRINTF) || !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/types.h> 32#include <sys/types.h>
@@ -120,7 +120,7 @@ mcleanup(str, n, p)
120 free(curobj); 120 free(curobj);
121} 121}
122 122
123#if !defined(HAVE_VSNPRINTF) 123#if !defined(HAVE_VSNPRINTF) || defined(BROKEN_SNPRINTF)
124int 124int
125vsnprintf(str, n, fmt, ap) 125vsnprintf(str, n, fmt, ap)
126 char *str; 126 char *str;
@@ -152,9 +152,9 @@ vsnprintf(str, n, fmt, ap)
152 (void) sigaction(SIGSEGV, &osa, NULL); 152 (void) sigaction(SIGSEGV, &osa, NULL);
153 return (ret); 153 return (ret);
154} 154}
155#endif /* !defined(HAVE_VSNPRINTF) */ 155#endif /* !defined(HAVE_VSNPRINTF) || defined(BROKEN_SNPRINTF) */
156 156
157#if !defined(HAVE_SNPRINTF) 157#if !defined(HAVE_SNPRINTF) || defined(BROKEN_SNPRINTF)
158int 158int
159#if __STDC__ 159#if __STDC__
160snprintf(char *str, size_t n, char const *fmt, ...) 160snprintf(char *str, size_t n, char const *fmt, ...)
@@ -176,6 +176,6 @@ snprintf(str, n, fmt, va_alist)
176 return (vsnprintf(str, n, fmt, ap)); 176 return (vsnprintf(str, n, fmt, ap));
177 va_end(ap); 177 va_end(ap);
178} 178}
179#endif /* !defined(HAVE_SNPRINTF) */ 179#endif /* !defined(HAVE_SNPRINTF) || defined(BROKEN_SNPRINTF) */
180 180
181#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */ 181#endif /* defined(BROKEN_SNPRINTF) || !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
diff --git a/configure.in b/configure.in
index 8e155f26b..dbc5a18ee 100644
--- a/configure.in
+++ b/configure.in
@@ -235,6 +235,23 @@ AC_CHECK_FUNC(getpagesize,
235 [AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])] 235 [AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
236) 236)
237 237
238# Check for broken snprintf
239if test "x$ac_cv_func_snprintf" = "xyes" ; then
240 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
241 AC_TRY_RUN(
242 [
243#include <stdio.h>
244int main(void){char b[5];snprintf(b,5,"123456789");return(b[4]!='\0');}
245 ],
246 [AC_MSG_RESULT(yes)],
247 [
248 AC_MSG_RESULT(no)
249 AC_DEFINE(BROKEN_SNPRINTF)
250 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
251 ]
252 )
253fi
254
238PAM_MSG="no" 255PAM_MSG="no"
239AC_ARG_WITH(pam, 256AC_ARG_WITH(pam,
240 [ --without-pam Disable PAM support ], 257 [ --without-pam Disable PAM support ],