You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2013/01/28 14:09:39 UTC
svn commit: r1439390 - in /httpd/httpd/branches/2.4.x: ./ include/ap_mmn.h
include/httpd.h server/util.c server/util_md5.c
Author: jim
Date: Mon Jan 28 13:09:39 2013
New Revision: 1439390
URL: http://svn.apache.org/viewvc?rev=1439390&view=rev
Log:
Merge r1422549, r1422712 from trunk:
add new ap_bin2hex() utility function
remove unnecessary cast
Submitted by: sf
Reviewed/backported by: jim
Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/include/ap_mmn.h
httpd/httpd/branches/2.4.x/include/httpd.h
httpd/httpd/branches/2.4.x/server/util.c
httpd/httpd/branches/2.4.x/server/util_md5.c
Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1422549,1422712
Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1439390&r1=1439389&r2=1439390&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Mon Jan 28 13:09:39 2013
@@ -400,6 +400,7 @@
* 20120211.8 (2.4.3-dev) Add sticky_separator to proxy_balancer_shared struct.
* 20120211.9 (2.4.4-dev) Add fgrab() to ap_slotmem_provider_t.
* 20120211.10 (2.4.4-dev) Add in bal_persist field to proxy_server_conf
+ * 20120211.11 (2.4.4-dev) Add ap_bin2hex()
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -407,7 +408,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20120211
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 10 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 11 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Modified: httpd/httpd/branches/2.4.x/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/httpd.h?rev=1439390&r1=1439389&r2=1439390&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/httpd.h (original)
+++ httpd/httpd/branches/2.4.x/include/httpd.h Mon Jan 28 13:09:39 2013
@@ -2209,6 +2209,14 @@ AP_DECLARE(void) ap_get_sload(ap_sload_t
*/
AP_DECLARE(void) ap_get_loadavg(ap_loadavg_t *ld);
+/**
+ * Convert binary data into a hex string
+ * @param src pointer to the data
+ * @param srclen length of the data
+ * @param dest pointer to buffer of length (2 * srclen + 1). The resulting
+ * string will be NUL-terminated.
+ */
+AP_DECLARE(void) ap_bin2hex(const void *src, apr_size_t srclen, char *dest);
#define AP_NORESTART APR_OS_START_USEERR + 1
Modified: httpd/httpd/branches/2.4.x/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/util.c?rev=1439390&r1=1439389&r2=1439390&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/util.c (original)
+++ httpd/httpd/branches/2.4.x/server/util.c Mon Jan 28 13:09:39 2013
@@ -1958,6 +1958,18 @@ AP_DECLARE(apr_size_t) ap_escape_errorlo
return (d - (unsigned char *)dest);
}
+AP_DECLARE(void) ap_bin2hex(const void *src, apr_size_t srclen, char *dest)
+{
+ const unsigned char *in = src;
+ apr_size_t i;
+
+ for (i = 0; i < srclen; i++) {
+ *dest++ = c2x_table[in[i] >> 4];
+ *dest++ = c2x_table[in[i] & 0xf];
+ }
+ *dest = '\0';
+}
+
AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *path)
{
apr_finfo_t finfo;
Modified: httpd/httpd/branches/2.4.x/server/util_md5.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/util_md5.c?rev=1439390&r1=1439389&r2=1439390&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/util_md5.c (original)
+++ httpd/httpd/branches/2.4.x/server/util_md5.c Mon Jan 28 13:09:39 2013
@@ -52,11 +52,9 @@
AP_DECLARE(char *) ap_md5_binary(apr_pool_t *p, const unsigned char *buf, int length)
{
- const char *hex = "0123456789abcdef";
apr_md5_ctx_t my_md5;
unsigned char hash[APR_MD5_DIGESTSIZE];
- char *r, result[33]; /* (MD5_DIGESTSIZE * 2) + 1 */
- int i;
+ char result[2 * APR_MD5_DIGESTSIZE + 1];
/*
* Take the MD5 hash of the string argument.
@@ -69,11 +67,7 @@ AP_DECLARE(char *) ap_md5_binary(apr_poo
apr_md5_update(&my_md5, buf, (unsigned int)length);
apr_md5_final(hash, &my_md5);
- for (i = 0, r = result; i < APR_MD5_DIGESTSIZE; i++) {
- *r++ = hex[hash[i] >> 4];
- *r++ = hex[hash[i] & 0xF];
- }
- *r = '\0';
+ ap_bin2hex(hash, APR_MD5_DIGESTSIZE, result);
return apr_pstrndup(p, result, APR_MD5_DIGESTSIZE*2);
}