[or-cvs] [tor/release-0.2.2] Detect signed size_t and report an error at configure time.

arma at torproject.org arma at torproject.org
Sat Jan 15 22:31:48 UTC 2011


commit 81d69f4c2d8a4517d1600c617924dec84228c889
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Jan 3 16:54:57 2011 -0500

    Detect signed size_t and report an error at configure time.
---
 changes/bug2337 |    3 +++
 configure.in    |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/changes/bug2337 b/changes/bug2337
new file mode 100644
index 0000000..a4f052d
--- /dev/null
+++ b/changes/bug2337
@@ -0,0 +1,3 @@
+  o Minor bugfixes
+    - Detect broken platforms with a signed size_t, and refuse to
+      build there.  Found and analyzed by doorss and rransom.
diff --git a/configure.in b/configure.in
index 68c593a..394be9e 100644
--- a/configure.in
+++ b/configure.in
@@ -548,6 +548,23 @@ if test "$tor_cv_time_t_signed" != no; then
             [Define to 1 iff time_t is signed])
 fi
 
+AC_CACHE_CHECK([whether size_t is signed], tor_cv_size_t_signed, [
+AC_RUN_IFELSE(AC_LANG_SOURCE([
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+int main(int c, char**v) { if (((size_t)-1)<0) return 1; else return 0; }]),
+  tor_cv_size_t_signed=no, tor_cv_size_t_signed=yes, tor_cv_size_t_signed=cross)
+])
+
+if test "$tor_cv_size_t_signed" = cross; then
+  AC_MSG_NOTICE([Cross compiling: assuming that size_t is not signed.])
+fi
+
+if test "$tor_cv_size_t_signed" = yes; then
+  AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
+fi
+
 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>





More information about the tor-commits mailing list