]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Whoops, overwriting hash with the hex isnt a good idea
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Apr 2008 16:09:26 +0000 (16:09 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 10 Apr 2008 16:09:26 +0000 (16:09 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9447 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_ripemd160.cpp

index 78b164315c154112a07c9ce893513244ff29f355..b6fd273444dafc4c1c345dc336485882b8afde5f 100644 (file)
@@ -64,8 +64,8 @@
 typedef                unsigned char           byte;
 typedef                unsigned int            dword;
 #else
-typedef                uint8_t                         byte;
-typedef                uint32_t                        dword;
+typedef                uint8_t                 byte;
+typedef                uint32_t                dword;
 #endif
 
 /* collect four bytes into one word: */
@@ -435,7 +435,7 @@ class ModuleRIPEMD160 : public Module
        }
 
        unsigned int* currkey;
-       char* chars;
+       const char* chars;
 
  public:
 
@@ -461,19 +461,19 @@ class ModuleRIPEMD160 : public Module
                }
                else if (strcmp("HEX", request->GetId()) == 0)
                {
-                       this->chars = (char*)SHA->GetOutputs();
+                       this->chars = SHA->GetOutputs();
                }
                else if (strcmp("SUM", request->GetId()) == 0)
                {
-                       static char* data;
-                       data = (char*)RMD((byte *)SHA->GetHashData().data(),SHA->GetHashData().length(), currkey);
+                       static char output[MAXBUF];
+                       char* data = (char*)RMD((byte *)SHA->GetHashData().data(),SHA->GetHashData().length(), currkey);
                        for (int i = 0, j = 0; i < RMDsize / 8; i++)
                        {
-                               data[j++] = chars[data[i] / 16];
-                               data[j++] = chars[data[i] % 16];
-                               data[j] = '\0';
+                               output[j++] = chars[data[i] / 16];
+                               output[j++] = chars[data[i] % 16];
+                               output[j] = '\0';
                        }
-                       return data;
+                       return output;
                }
                else if (strcmp("NAME", request->GetId()) == 0)
                {