Do not assume the data field of an address structure is an aligned pointer.
authorGuy Harris <guy@alum.mit.edu>
Mon, 11 May 2015 22:10:54 +0000 (15:10 -0700)
committerGuy Harris <guy@alum.mit.edu>
Mon, 11 May 2015 22:11:21 +0000 (22:11 +0000)
There is *no* guarantee that it's aligned on a 4-byte boundary, and
there is *no* guarantee that you can safely dereference an unaligned
pointer.  See bug 11172 for a crash on Solaris/SPARC caused by those
assumptions both being false.

Change-Id: I30d97aebd42283545f5b8f6d50fa09c5b476ec47
Reviewed-on: https://code.wireshark.org/review/8412
Reviewed-by: Guy Harris <guy@alum.mit.edu>
epan/dissectors/packet-ssl-utils.c

index 932dd40ba17ecfd74284279db5d200182f784a51..b2ac8b733ac26cc51f2e2f7f6b5002c4361bd801 100644 (file)
@@ -42,6 +42,7 @@
 #include <wsutil/file_util.h>
 #include <wsutil/str_util.h>
 #include <wsutil/report_err.h>
+#include <wsutil/pint.h>
 #include "packet-x509af.h"
 #include "packet-x509if.h"
 #include "packet-ssl-utils.h"
@@ -4127,16 +4128,16 @@ ssl_private_key_hash  (gconstpointer v)
 {
     const SslService *key;
     guint        l, hash, len ;
-    const guintcur;
+    const guint8 *cur;
 
     key  = (const SslService *)v;
     hash = key->port;
     len  = key->addr.len;
     hash |= len << 16;
-    cur  = (const guint*) key->addr.data;
+    cur  = (const guint*) key->addr.data;
 
-    for (l=4; (l<len); l+=4, cur++)
-        hash = hash ^ (*cur);
+    for (l=4; (l<len); l+=4, cur+=4)
+        hash = hash ^ pntoh32(cur);
 
     return hash;
 }