dgaudet 98/03/28 13:58:40
Modified: src CHANGES
src/ap ap_snprintf.c
src/include conf.h
Log:
ap_cvt and its ilk weren't threadsafe
remove HAVE_CVT because we need threadsafe functions
Revision Changes Path
1.745 +4 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.744
retrieving revision 1.745
diff -u -r1.744 -r1.745
--- CHANGES 1998/03/28 21:33:40 1.744
+++ CHANGES 1998/03/28 21:58:36 1.745
@@ -1,5 +1,9 @@
Changes with Apache 1.3b6
+ *) The floating point ap_snprintf code wasn't threadsafe.
+ Had to remove the HAVE_CVT macro in order to do threadsafe
+ calling of the ?cvt() floating point routines. [Dean Gaudet]
+
*) PORT: Add the SCO_SV port. [Jim Jagielski] PR#1962
*) PORT: IRIX needs the -n32 flag iff using the 'cc' compiler
1.15 +18 -26 apache-1.3/src/ap/ap_snprintf.c
Index: ap_snprintf.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/ap/ap_snprintf.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ap_snprintf.c 1998/03/28 11:58:15 1.14
+++ ap_snprintf.c 1998/03/28 21:58:38 1.15
@@ -64,17 +64,9 @@
#include <stdlib.h>
#include <math.h>
-#ifdef HAVE_CVT
-
-#define ap_ecvt ecvt
-#define ap_fcvt fcvt
-#define ap_gcvt gcvt
-
-#else
-
/*
* cvt.c - IEEE floating point formatting routines for FreeBSD
- * from GNU libc-4.6.27
+ * from GNU libc-4.6.27. Modified to be thread safe.
*/
/*
@@ -86,12 +78,12 @@
#define NDIG 80
-static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int
eflag)
+/* buf must have at least NDIG bytes */
+static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int
eflag, char *buf)
{
register int r2;
double fi, fj;
register char *p, *p1;
- static char buf[NDIG];
if (ndigits >= NDIG - 1)
ndigits = NDIG - 2;
@@ -160,14 +152,14 @@
return (buf);
}
-static char *ap_ecvt(double arg, int ndigits, int *decpt, int *sign)
+static char *ap_ecvt(double arg, int ndigits, int *decpt, int *sign, char
*buf)
{
- return (ap_cvt(arg, ndigits, decpt, sign, 1));
+ return (ap_cvt(arg, ndigits, decpt, sign, 1, buf));
}
-static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign)
+static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char
*buf)
{
- return (ap_cvt(arg, ndigits, decpt, sign, 0));
+ return (ap_cvt(arg, ndigits, decpt, sign, 0, buf));
}
/*
@@ -180,8 +172,9 @@
int sign, decpt;
register char *p1, *p2;
register int i;
+ char buf1[NDIG];
- p1 = ap_ecvt(number, ndigit, &decpt, &sign);
+ p1 = ap_ecvt(number, ndigit, &decpt, &sign, buf1);
p2 = buf;
if (sign)
*p2++ = '-';
@@ -233,8 +226,6 @@
return (buf);
}
-#endif /* HAVE_CVT */
-
typedef enum {
NO = 0, YES = 1
} boolean_e;
@@ -394,18 +385,19 @@
* The sign is returned in the is_negative argument (and is not placed
* in buf).
*/
-static char *
- conv_fp(register char format, register double num,
-boolean_e add_dp, int precision, bool_int *is_negative, char *buf, int *len)
+static char *conv_fp(register char format, register double num,
+ boolean_e add_dp, int precision, bool_int *is_negative,
+ char *buf, int *len)
{
register char *s = buf;
register char *p;
int decimal_point;
+ char buf1[NDIG];
if (format == 'f')
- p = ap_fcvt(num, precision, &decimal_point, is_negative);
+ p = ap_fcvt(num, precision, &decimal_point, is_negative, buf1);
else /* either e or E format */
- p = ap_ecvt(num, precision + 1, &decimal_point, is_negative);
+ p = ap_ecvt(num, precision + 1, &decimal_point, is_negative, buf1);
/*
* Check for Infinity and NaN
@@ -493,9 +485,9 @@
{
register int mask = (1 << nbits) - 1;
register char *p = buf_end;
- static char low_digits[] = "0123456789abcdef";
- static char upper_digits[] = "0123456789ABCDEF";
- register char *digits = (format == 'X') ? upper_digits : low_digits;
+ static const char low_digits[] = "0123456789abcdef";
+ static const char upper_digits[] = "0123456789ABCDEF";
+ register const char *digits = (format == 'X') ? upper_digits :
low_digits;
do {
*--p = digits[num & mask];
1.198 +0 -1 apache-1.3/src/include/conf.h
Index: conf.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/conf.h,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -r1.197 -r1.198
--- conf.h 1998/03/28 16:53:18 1.197
+++ conf.h 1998/03/28 21:58:39 1.198
@@ -602,7 +602,6 @@
#undef NO_SETSID
#undef NO_USE_SIGACTION
#undef NO_LINGCLOSE
-#define HAVE_CVT 1
extern char *crypt(char *pw, char *salt);
typedef int rlim_t;
#define HAVE_SYSLOG 1