martin 99/04/09 05:57:11
Modified: src CHANGES
src/support htdigest.c
src/main util_md5.c http_core.c
src/include util_md5.h
Log:
EBCDIC platforms: David submitted patches for two bugs in the
MD5 digest port for EBCDIC machines:
a) the htdigest utility overwrote the old contents of the digest file
b) the Content-MD5 header value (ContentDigest directive) was wrong
when the returned file was not converted from EBCDIC, but was a
binary (e.g., image file) in the first place.
Submitted by: David McCreedy <[EMAIL PROTECTED]>
Reviewed by: Martin Kraemer
Revision Changes Path
1.1303 +8 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1302
retrieving revision 1.1303
diff -u -r1.1302 -r1.1303
--- CHANGES 1999/04/08 22:17:45 1.1302
+++ CHANGES 1999/04/09 12:57:04 1.1303
@@ -1,4 +1,12 @@
Changes with Apache 1.3.7
+ *) EBCDIC platforms: David submitted patches for two bugs in the
+ MD5 digest port for EBCDIC machines:
+ a) the htdigest utility overwrote the old contents of the digest file
+ b) the Content-MD5 header value (ContentDigest directive) was wrong
+ when the returned file was not converted from EBCDIC, but was a
+ binary (e.g., image file) in the first place.
+ [David McCreedy <[EMAIL PROTECTED]>]
+
*) support/htpasswd now permits the password to be specified on the
command line with the '-b' switch. This is useful when passwords
need to be maintained by scripts -- particularly in the Win32
1.22 +5 -0 apache-1.3/src/support/htdigest.c
Index: htdigest.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/support/htdigest.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- htdigest.c 1999/01/17 22:30:31 1.21
+++ htdigest.c 1999/04/09 12:57:06 1.22
@@ -19,8 +19,13 @@
#endif
#include "ap_md5.h"
+#ifdef CHARSET_EBCDIC
+#define LF '\n'
+#define CR '\r'
+#else
#define LF 10
#define CR 13
+#endif /* CHARSET_EBCDIC */
#define MAX_STRING_LEN 256
1.19 +25 -0 apache-1.3/src/main/util_md5.c
Index: util_md5.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/util_md5.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- util_md5.c 1999/04/08 20:56:43 1.18
+++ util_md5.c 1999/04/09 12:57:07 1.19
@@ -187,6 +187,29 @@
return encodedDigest;
}
+#ifdef CHARSET_EBCDIC
+
+API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile, int convert)
+{
+ AP_MD5_CTX context;
+ unsigned char buf[1000];
+ long length = 0;
+ int nbytes;
+
+ ap_MD5Init(&context);
+ while ((nbytes = fread(buf, 1, sizeof(buf), infile))) {
+ length += nbytes;
+ if (!convert) {
+ ascii2ebcdic(buf, buf, nbytes);
+ }
+ ap_MD5Update(&context, buf, nbytes);
+ }
+ rewind(infile);
+ return ap_md5contextTo64(p, &context);
+}
+
+#else
+
API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile)
{
AP_MD5_CTX context;
@@ -202,3 +225,5 @@
rewind(infile);
return ap_md5contextTo64(p, &context);
}
+
+#endif /* CHARSET_EBCDIC */
1.258 +17 -9 apache-1.3/src/main/http_core.c
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -r1.257 -r1.258
--- http_core.c 1999/04/08 20:56:43 1.257
+++ http_core.c 1999/04/09 12:57:07 1.258
@@ -2962,6 +2962,9 @@
#ifdef USE_MMAP_FILES
caddr_t mm;
#endif
+#ifdef CHARSET_EBCDIC
+ int convert_flag;
+#endif
/* This handler has no use for a request body (yet), but we still
* need to read and discard it if the client sent one.
@@ -3044,22 +3047,27 @@
ap_unblock_alarms();
#endif
- if (d->content_md5 & 1) {
- ap_table_setn(r->headers_out, "Content-MD5",
- ap_md5digest(r->pool, f));
- }
-
- rangestatus = ap_set_byterange(r);
#ifdef CHARSET_EBCDIC
- /* To make serving of "raw ASCII text" files easy (they serve faster
+ /* To make serving of "raw ASCII text" files easy (they serve faster
* since they don't have to be converted from EBCDIC), a new
* "magic" type prefix was invented: text/x-ascii-{plain,html,...}
* If we detect one of these content types here, we simply correct
* the type to the real text/{plain,html,...} type. Otherwise, we
* set a flag that translation is required later on.
*/
- ap_checkconv(r);
-#endif /*CHARSET_EBCDIC*/
+ convert_flag = ap_checkconv(r);
+ if (d->content_md5 & 1) {
+ ap_table_setn(r->headers_out, "Content-MD5",
+ ap_md5digest(r->pool, f, convert_flag));
+ }
+#else
+ if (d->content_md5 & 1) {
+ ap_table_setn(r->headers_out, "Content-MD5",
+ ap_md5digest(r->pool, f));
+ }
+#endif /* CHARSET_EBCDIC */
+
+ rangestatus = ap_set_byterange(r);
ap_send_http_header(r);
1.18 +4 -0 apache-1.3/src/include/util_md5.h
Index: util_md5.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/include/util_md5.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- util_md5.h 1999/01/01 19:04:42 1.17
+++ util_md5.h 1999/04/09 12:57:09 1.18
@@ -67,7 +67,11 @@
API_EXPORT(char *) ap_md5(pool *a, const unsigned char *string);
API_EXPORT(char *) ap_md5_binary(pool *a, const unsigned char *buf, int len);
API_EXPORT(char *) ap_md5contextTo64(pool *p, AP_MD5_CTX * context);
+#ifdef CHARSET_EBCDIC
+API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile, int convert);
+#else
API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile);
+#endif /* CHARSET_EBCDIC */
#ifdef __cplusplus
}