myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 3a5db3c216


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 3a5db3c216a14377abc3ff4f5553e82db5e2afd7
Date: Thu, 22 Oct 2009 22:25:32 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  3a5db3c216a14377abc3ff4f5553e82db5e2afd7 (commit)
      from  1787d92b17a7b99a7cc4963c49df09ac9799a7bf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 3a5db3c216a14377abc3ff4f5553e82db5e2afd7
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Oct 23 00:25:18 2009 +0200

    Avoid unnecessary shifts while trasforming to the final MD5 hash.

diff --git a/myserver/src/base/md5/md5.cpp b/myserver/src/base/md5/md5.cpp
index 58ff70c..c0864f8 100644
--- a/myserver/src/base/md5/md5.cpp
+++ b/myserver/src/base/md5/md5.cpp
@@ -57,7 +57,7 @@ Md5::~Md5 ()
 char* Md5::end (char *buf)
 {
   unsigned char tmp[16];
-
+  char *ret = buf;
   if (!buf)
     return NULL;
 
@@ -67,11 +67,11 @@ char* Md5::end (char *buf)
 
   for (long i = 0; i < 16; i++)
     {
-      buf[(i << 1)] = hex[tmp[i] >> 4];
-      buf[(i << 1) + 1] = hex[tmp[i] & 0x0f];
+      *buf++ = hex[tmp[i] >> 4];
+      *buf++ = hex[tmp[i] & 0x0f];
     }
 
-  buf[32] = '\0';
+  *buf = '\0';
 
-  return buf;
+  return ret;
 }
diff --git a/myserver/tests/test_md5.cpp b/myserver/tests/test_md5.cpp
index 312b345..9e5cd72 100644
--- a/myserver/tests/test_md5.cpp
+++ b/myserver/tests/test_md5.cpp
@@ -1,6 +1,6 @@
 /*
  MyServer
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009 Free Software Foundation, Inc.
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
@@ -52,12 +52,12 @@ public:
 
     md5->init ();
     md5->update (msg, strlen (msg));
-    md5->end (out);
+    char *ret = md5->end (out);
+
+    CPPUNIT_ASSERT_EQUAL (ret, &out[0]);
 
     for (int i = 0; i < 32; i++)
-    {
       CPPUNIT_ASSERT_EQUAL (tolower (expected[i]), tolower (out[i]));
-    }
 
   }
 };

-----------------------------------------------------------------------

Summary of changes:
 myserver/src/base/md5/md5.cpp |   10 +++++-----
 myserver/tests/test_md5.cpp   |    8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]