You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Daniel Shahaf <d....@daniel.shahaf.name> on 2012/02/20 00:57:40 UTC

[PATCH] APR_EXPAND_VAR: detect infinite loops

[[[
Index: build/apr_common.m4
===================================================================
--- build/apr_common.m4	(revision 1291093)
+++ build/apr_common.m4	(working copy)
@@ -696,11 +696,17 @@
 AC_DEFUN([APR_EXPAND_VAR], [
 ap_last=
 ap_cur="$2"
-while test "x${ap_cur}" != "x${ap_last}";
+ap_expand_iters=0
+while test "x${ap_cur}" != "x${ap_last}" && test x$ap_expand_iters != x500;
 do
   ap_last="${ap_cur}"
   ap_cur=`eval "echo ${ap_cur}"`
+  ap_expand_iters=`expr 1 + $ap_expand_iters`
 done
+if test x$ap_expand_iters = x500
+then
+  AC_MSG_ERROR([APR_EXPAND_VAR($1,$2): infinite loop])
+fi
 $1="${ap_cur}"
 ])
 
]]]

I ran into this doing
% ./configure --prefix=\$prefix
with one backslash too many.

Not tested.