Skip to content

memcache.go has possible hash collisions, leading to wrong values saved/retrieved from cache #168

Open

Description

@dbardbar

In memcache.go there's TemplatesShard which has a map with uint32 as key.
The key is computed as a hash of the sender's IP and template ID.

It is possible to have multiple senders or multiple template IDs that will result in in the same hash.
In such a case, they will overwrite each-other in the cache, leading to incorrect parsing of the traffic from the other sender.
In the best case scenario, the incorrectly parsed packets would cause some error and the packet would be ignored. In the worst case scenario, the parsing would succeed, but would result in garbage values.

I do not understand the motivation of making this map with a key of uint32 and going through the trouble of manually computing the hash. If the code would use a map with a struct holding the IP and ID, then the code would be much simpler and the problem described here would never happen.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions