about summary refs log tree commit diff
path: root/custom_mutators/gramatron/hashmap.c
diff options
context:
space:
mode:
authoryihellen <42916179+yihellen@users.noreply.github.com>2022-05-26 07:21:59 -0700
committerGitHub <noreply@github.com>2022-05-26 16:21:59 +0200
commit4103ee43e249ee14bd16baf080489a107bbfdbf5 (patch)
tree887f53dea8b898a0fd762c45dd06474ceca67f1d /custom_mutators/gramatron/hashmap.c
parent5ad760a77b0fea14a63c471f3fb0e3ffa85a222a (diff)
downloadafl++-4103ee43e249ee14bd16baf080489a107bbfdbf5.tar.gz
Add automaton parser (#1426)
* have compilable program

* enable read in file

* add hashmap usage

* add build hashmap; WIP; test if constructed correctly tomorrow

* add testcase to test hashmap

* add sorted symbols list

* build symbols dictionary

* clean up DEBUG

* successfully find automaton path

* fix all memory leaks

* test if automaton same with example

* able to iterate through files in a folder

* finish testing on one random queue
wip
- change macro values
- add bound checking

* add bound checking to program length

* add bound checking to program walk length

* add boundary check to terminal number, terminal lengths and program length

* commit test makefile

* add makefile

* able to add seeds to gramatron

* remove useless argument in automaton_parser

* add automaton parser to gramfuzz

* change build

* revert test.c to original state

* add makefile to test.c for testing
Diffstat (limited to 'custom_mutators/gramatron/hashmap.c')
-rw-r--r--custom_mutators/gramatron/hashmap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/custom_mutators/gramatron/hashmap.c b/custom_mutators/gramatron/hashmap.c
index 09715b87..4f97e085 100644
--- a/custom_mutators/gramatron/hashmap.c
+++ b/custom_mutators/gramatron/hashmap.c
@@ -151,7 +151,7 @@ static unsigned long crc32_tab[] = {
 
 /* Return a 32-bit CRC of the contents of the buffer. */
 
-unsigned long crc32(const unsigned char *s, unsigned int len) {
+unsigned long custom_crc32(const unsigned char *s, unsigned int len) {
 
   unsigned int  i;
   unsigned long crc32val;
@@ -171,8 +171,9 @@ unsigned long crc32(const unsigned char *s, unsigned int len) {
  * Hashing function for a string
  */
 unsigned int hashmap_hash_int(hashmap_map *m, char *keystring) {
+  unsigned int keystring_len = strlen(keystring);
 
-  unsigned long key = crc32((unsigned char *)(keystring), strlen(keystring));
+  unsigned long key = custom_crc32((unsigned char *)(keystring), keystring_len);
 
   /* Robert Jenkins' 32 bit Mix Function */
   key += (key << 12);