diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-02 14:38:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-02 14:38:54 +0000 |
commit | 15a8471c0edc4134f57c19884c033a63f49a04dd (patch) | |
tree | 4465bb0b1198f1869163706e6cfeeaba5ff3fabf /src/regex/regex_block_lib.c | |
parent | 2a453cf6aec60af36f655bd053847ab15ff7ae8f (diff) | |
download | gnunet-15a8471c0edc4134f57c19884c033a63f49a04dd.tar.gz gnunet-15a8471c0edc4134f57c19884c033a63f49a04dd.zip |
-implementing regex test
Diffstat (limited to 'src/regex/regex_block_lib.c')
-rw-r--r-- | src/regex/regex_block_lib.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index 7fcb1a7f1..7b273e6d8 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c | |||
@@ -96,11 +96,18 @@ GNUNET_NETWORK_STRUCT_END | |||
96 | * Test if this block is marked as being an accept state. | 96 | * Test if this block is marked as being an accept state. |
97 | * | 97 | * |
98 | * @param block block to test | 98 | * @param block block to test |
99 | * @param size number of bytes in block | ||
99 | * @return GNUNET_YES if the block is accepting, GNUNET_NO if not | 100 | * @return GNUNET_YES if the block is accepting, GNUNET_NO if not |
100 | */ | 101 | */ |
101 | int | 102 | int |
102 | GNUNET_BLOCK_is_accepting (const struct RegexBlock *block) | 103 | GNUNET_BLOCK_is_accepting (const struct RegexBlock *block, |
104 | size_t size) | ||
103 | { | 105 | { |
106 | if (size < sizeof (struct RegexBlock)) | ||
107 | { | ||
108 | GNUNET_break_op (0); | ||
109 | return GNUNET_SYSERR; | ||
110 | } | ||
104 | return ntohs (block->is_accepting); | 111 | return ntohs (block->is_accepting); |
105 | } | 112 | } |
106 | 113 | ||
@@ -316,7 +323,7 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
316 | destinations = (const struct GNUNET_HashCode *) &block[1]; | 323 | destinations = (const struct GNUNET_HashCode *) &block[1]; |
317 | edges = (const struct EdgeInfo *) &destinations[num_destinations]; | 324 | edges = (const struct EdgeInfo *) &destinations[num_destinations]; |
318 | aux = (const char *) &edges[num_edges]; | 325 | aux = (const char *) &edges[num_edges]; |
319 | total = sizeof (struct RegexBlock) + num_destinations * sizeof (struct GNUNET_HashCode) + num_edges + sizeof (struct EdgeInfo) + len; | 326 | total = sizeof (struct RegexBlock) + num_destinations * sizeof (struct GNUNET_HashCode) + num_edges * sizeof (struct EdgeInfo) + len; |
320 | if (size < total) | 327 | if (size < total) |
321 | { | 328 | { |
322 | GNUNET_break_op (0); | 329 | GNUNET_break_op (0); |
@@ -326,6 +333,9 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
326 | total += ntohs (edges[n].token_length); | 333 | total += ntohs (edges[n].token_length); |
327 | if (size != total) | 334 | if (size != total) |
328 | { | 335 | { |
336 | fprintf (stderr, "Expected %u, got %u\n", | ||
337 | (unsigned int) size, | ||
338 | (unsigned int) total); | ||
329 | GNUNET_break_op (0); | 339 | GNUNET_break_op (0); |
330 | return GNUNET_SYSERR; | 340 | return GNUNET_SYSERR; |
331 | } | 341 | } |