Consistently include <config.h> in all C source files and never in header files.
[platform/upstream/dbus.git] / dbus / dbus-md5.c
index b246b35..af71d5c 100644 (file)
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /* dbus-md5.c md5 implementation (based on L Peter Deutsch implementation)
  *
  * Copyright (C) 2003 Red Hat Inc.
@@ -34,6 +34,7 @@
  * <ghost@aladdin.com>.
  */
 
+#include <config.h>
 #include "dbus-internals.h"
 #include "dbus-md5.h"
 #include <string.h>
@@ -54,7 +55,7 @@
  * The implementation of MD5 (see http://www.ietf.org/rfc/rfc1321.txt).
  * This MD5 implementation was written by L. Peter Deutsch and
  * is not derived from the RSA reference implementation in the
- * RFC. The version included in D-BUS comes from the Ghostscript
+ * RFC. The version included in D-Bus comes from the Ghostscript
  * 7.05 distribution.
  *
  * @{
@@ -157,7 +158,7 @@ main(int argc, char **argv)
 #define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
 #define T63    0x2ad7d2bb
 #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+#endif /* !DOXYGEN_SHOULD_SKIP_THIS */
 
 static void
 md5_process(DBusMD5Context *context, const unsigned char *data /*[64]*/)
@@ -451,7 +452,7 @@ _dbus_md5_final (DBusMD5Context   *context,
   /* some kind of security paranoia, though it seems pointless
    * to me given the nonzeroed stuff flying around
    */
-  memset ((void*)context, '\0', sizeof (DBusMD5Context));
+  _DBUS_ZERO(*context);
 
   return TRUE;
 }
@@ -475,7 +476,7 @@ _dbus_md5_compute (const DBusString *data,
 
   _dbus_md5_update (&context, data);
 
-  if (!_dbus_string_init (&digest, _DBUS_INT_MAX))
+  if (!_dbus_string_init (&digest))
     return FALSE;
 
   if (!_dbus_md5_final (&context, &digest))
@@ -485,6 +486,8 @@ _dbus_md5_compute (const DBusString *data,
                                 _dbus_string_get_length (ascii_output)))
     goto error;
 
+  _dbus_string_free (&digest);
+  
   return TRUE;
 
  error:
@@ -510,7 +513,7 @@ check_md5_binary (const unsigned char *input,
   _dbus_string_init_const_len (&input_str, input, input_len);
   _dbus_string_init_const (&expected_str, expected);
 
-  if (!_dbus_string_init (&results, _DBUS_INT_MAX))
+  if (!_dbus_string_init (&results))
     _dbus_assert_not_reached ("no memory for md5 results");
 
   if (!_dbus_md5_compute (&input_str, &results))