httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <>
Subject [PATCH] ap_md5: unsigned char -> char !?
Date Fri, 23 Oct 1998 07:15:12 GMT

While I ported the DSO stuff to UnixWare 7 I recognized that I get a nasty
warning from the SVR4 compiler about a prototype mismatch. It's in util_md5.c,
line 114 where we pass a "const unsigned char *" argument to strlen() but
strlen() is (also on this platform) defined to use an argument of type "const
char *" (as ISO C requires). For GCC platforms this is no problem, but
other compilers complain here.

Usually we could cast the argument to strlen() to this type, but IMHO it's more
correct to change the string argument type of the ap_md5() function to "const
char *" and instead do the cast to "const unsigned char *" for the string
variable when passing to ap_md5_binary().

The patch is appended below. Give me your opinion.
Perhaps I'm wrong and it's more correct to cast the argument to strlen()
or to do nothing or whatever... 

                                       Ralf S. Engelschall

Index: include/util_md5.h
RCS file: /e/apache/REPOS/apache-1.3/src/include/util_md5.h,v
retrieving revision 1.16
diff -u -r1.16 util_md5.h
--- util_md5.h	1998/09/06 17:12:18	1.16
+++ util_md5.h	1998/10/23 07:06:44
@@ -64,7 +64,7 @@
 #include "ap_md5.h"
-API_EXPORT(char *) ap_md5(pool *a, const unsigned char *string);
+API_EXPORT(char *) ap_md5(pool *a, const 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);
 API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile);
Index: main/util_md5.c
RCS file: /e/apache/REPOS/apache-1.3/src/main/util_md5.c,v
retrieving revision 1.15
diff -u -r1.15 util_md5.c
--- util_md5.c	1998/09/06 17:12:18	1.15
+++ util_md5.c	1998/10/23 07:06:23
@@ -109,9 +109,9 @@
     return ap_pstrdup(p, result);
-API_EXPORT(char *) ap_md5(pool *p, const unsigned char *string)
+API_EXPORT(char *) ap_md5(pool *p, const char *string)
-    return ap_md5_binary(p, string, strlen(string));
+    return ap_md5_binary(p, (const unsigned char *)string, strlen(string));
 /* these portions extracted from mpack, John G. Myers - */

View raw message