< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

Re: [reSIProcate] [PATCH] Add more and better salt values to callid computation


Aron Rosenberg wrote:

Here is a revised patch using the append method with proper Win32 types.


That's not quite right. You need to take the *address* of the various process/thread IDs before casting them to a char pointer. Corrected patch attached.

/a
Index: resip/stack/Helper.cxx
===================================================================
--- resip/stack/Helper.cxx      (revision 6909)
+++ resip/stack/Helper.cxx      (working copy)
@@ -552,7 +552,23 @@
 Helper::computeCallId()
 {
    static Data hostname = DnsUtil::getLocalHostName();
-   Data hostAndSalt(hostname + Random::getRandomHex(8));
+   Data hostAndSalt(hostname + Random::getRandomHex(16));
+#ifndef USE_SSL
+#if defined(__linux__) || defined(__APPLE__)
+   pid_t pid = getpid();
+   hostAndSalt.append((char*)&pid,sizeof(pid));
+#endif
+#ifdef __APPLE__
+   pthread_t thread = pthread_self();
+   hostAndSalt.append((char*)&thread,sizeof(thread));
+#endif
+#ifdef WIN32
+   DWORD proccessId = ::GetCurrentProcessId();
+   DWORD threadId = ::GetCurrentThreadId();
+   hostAndSalt.append((char*)&proccessId,sizeof(proccessId));
+   hostAndSalt.append((char*)&threadId,sizeof(threadId));
+#endif
+#endif
    return hostAndSalt.md5().base64encode(true);
 }