twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

commit 3ea91942f5dd739ccccee2ff2d996081003d654a
parent c5a65df2f40125fdd7d35f29822038d0d93fc5b5
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Mon,  4 Jun 2018 10:40:18 +0200

Addressing #5336.

Diffstat:
Msrc/twister/taler-twister-service.c | 30++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c @@ -918,6 +918,13 @@ flip_object (struct MHD_Connection *con, { char *target; json_t *parent; + #define CROCKFORD_MAX_INDEX 31 + char crockford_chars[] = {'0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', + 'J', 'K', 'M', 'N', 'P', 'Q', + 'R', 'S', 'T', 'V', 'W', 'X', + 'Y', 'Z'}; // index: 0-31 if (GNUNET_OK != walk_response_object (flip_path, &parent, @@ -930,7 +937,8 @@ flip_object (struct MHD_Connection *con, json_t *child = NULL; const char *current_value; char *current_value_flip; - uint32_t index; + uint32_t crockford_index; + uint32_t flip_index; if (json_is_object (parent)) child = json_object_get (parent, target); @@ -949,11 +957,19 @@ flip_object (struct MHD_Connection *con, #warning When free this? current_value_flip = GNUNET_strdup (current_value); - index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - strlen (current_value_flip)); + crockford_index = GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, + CROCKFORD_MAX_INDEX + 1); - /* flip the LSB. */ - current_value_flip[index] ^= 1; + flip_index = GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, + strlen (current_value_flip)); + + /* flip the LSB. WARNING: if the flipping does NOT + * reach a Crockford-friendly char, then the test cases + * will get disoriented by "400 Bad request" responses. */ + current_value_flip[flip_index] = + crockford_chars[crockford_index]; TALER_LOG_INFO ("Flipping %s to %s\n", current_value, @@ -1413,7 +1429,9 @@ create_response (void *cls, { TALER_LOG_DEBUG ("Will flip path: %s\n", flip_path_dl); - flip_object (con, hr->json, flip_path_dl); + flip_object (con, + hr->json, + flip_path_dl); } if ('\0' != delete_path[0])