diff --git a/glib/ghash.c b/glib/ghash.c index 6569435aa..92c16c9a7 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -151,11 +151,19 @@ * g_direct_hash() is also the appropriate hash function for keys * of the form GINT_TO_POINTER (n) (or similar macros). * - * The hash values should be evenly - * distributed over a fairly large range? The modulus is taken with the - * hash table size (a prime number) to find the 'bucket' to place each - * key into. The function should also be very fast, since it is called - * for each key lookup. + * A good hash functions should produce + * hash values that are evenly distributed over a fairly large range. + * The modulus is taken with the hash table size (a prime number) to + * find the 'bucket' to place each key into. The function should also + * be very fast, since it is called for each key lookup. + * + * Note that the hash functions provided by GLib have these qualities, + * but are not particularly robust against manufactured keys that + * cause hash collisions. Therefore, you should consider choosing + * a more secure hash function when using a GHashTable with keys + * that originate in untrusted data (such as HTTP requests). + * Using g_str_hash() in that situation might make your application + * vulerable to Algorithmic Complexity Attacks. * * Returns: the hash value corresponding to the key */