Merge remote-tracking branch 'dgoulet/bug19567_029_01'

This commit is contained in:
Nick Mathewson 2016-07-05 12:14:04 -04:00
commit 87758dbebc
3 changed files with 9 additions and 10 deletions

View File

@ -34,11 +34,11 @@
#define SR_SRV_MSG_LEN \ #define SR_SRV_MSG_LEN \
(SR_SRV_TOKEN_LEN + sizeof(uint64_t) + sizeof(uint32_t) + DIGEST256_LEN) (SR_SRV_TOKEN_LEN + sizeof(uint64_t) + sizeof(uint32_t) + DIGEST256_LEN)
/* Length of base64 encoded commit NOT including the NULL terminated byte. /* Length of base64 encoded commit NOT including the NUL terminated byte.
* Formula is taken from base64_encode_size. */ * Formula is taken from base64_encode_size. This adds up to 56 bytes. */
#define SR_COMMIT_BASE64_LEN \ #define SR_COMMIT_BASE64_LEN \
(((SR_COMMIT_LEN - 1) / 3) * 4 + 4) (((SR_COMMIT_LEN - 1) / 3) * 4 + 4)
/* Length of base64 encoded reveal NOT including the NULL terminated byte. /* Length of base64 encoded reveal NOT including the NUL terminated byte.
* Formula is taken from base64_encode_size. This adds up to 56 bytes. */ * Formula is taken from base64_encode_size. This adds up to 56 bytes. */
#define SR_REVEAL_BASE64_LEN \ #define SR_REVEAL_BASE64_LEN \
(((SR_REVEAL_LEN - 1) / 3) * 4 + 4) (((SR_REVEAL_LEN - 1) / 3) * 4 + 4)

View File

@ -617,26 +617,24 @@ disk_state_update(void)
/* Reset current disk state. */ /* Reset current disk state. */
disk_state_reset(); disk_state_reset();
/* First, update elements that we don't need to iterate over a list to /* First, update elements that we don't need to do a construction. */
* construct something. */
sr_disk_state->Version = sr_state->version; sr_disk_state->Version = sr_state->version;
sr_disk_state->ValidUntil = sr_state->valid_until; sr_disk_state->ValidUntil = sr_state->valid_until;
sr_disk_state->ValidAfter = sr_state->valid_after; sr_disk_state->ValidAfter = sr_state->valid_after;
/* Shared random values. */ /* Shared random values. */
next = &sr_disk_state->SharedRandValues; next = &sr_disk_state->SharedRandValues;
*next = NULL;
if (sr_state->previous_srv != NULL) { if (sr_state->previous_srv != NULL) {
*next = line = tor_malloc_zero(sizeof(config_line_t)); *next = line = tor_malloc_zero(sizeof(config_line_t));
line->key = tor_strdup(dstate_prev_srv_key); line->key = tor_strdup(dstate_prev_srv_key);
disk_state_put_srv_line(sr_state->previous_srv, line); disk_state_put_srv_line(sr_state->previous_srv, line);
/* Go to the next shared random value. */
next = &(line->next); next = &(line->next);
} }
if (sr_state->current_srv != NULL) { if (sr_state->current_srv != NULL) {
*next = line = tor_malloc_zero(sizeof(*line)); *next = line = tor_malloc_zero(sizeof(*line));
line->key = tor_strdup(dstate_cur_srv_key); line->key = tor_strdup(dstate_cur_srv_key);
disk_state_put_srv_line(sr_state->current_srv, line); disk_state_put_srv_line(sr_state->current_srv, line);
next = &(line->next);
} }
/* Parse the commits and construct config line(s). */ /* Parse the commits and construct config line(s). */

View File

@ -944,13 +944,14 @@ test_utils(void *arg)
/* Testing commitments_are_the_same(). Currently, the check is to test the /* Testing commitments_are_the_same(). Currently, the check is to test the
* value of the encoded commit so let's make sure that actually works. */ * value of the encoded commit so let's make sure that actually works. */
{ {
/* Payload of 55 bytes that is the length of /* Payload of 57 bytes that is the length of sr_commit_t->encoded_commit.
* sr_commit_t->encoded_commit. */ * 56 bytes of payload and a NUL terminated byte at the end ('\x00')
* which comes down to SR_COMMIT_BASE64_LEN + 1. */
const char *payload = const char *payload =
"\x5d\xb9\x60\xb6\xcc\x51\x68\x52\x31\xd9\x88\x88\x71\x71\xe0\x30" "\x5d\xb9\x60\xb6\xcc\x51\x68\x52\x31\xd9\x88\x88\x71\x71\xe0\x30"
"\x59\x55\x7f\xcd\x61\xc0\x4b\x05\xb8\xcd\xc1\x48\xe9\xcd\x16\x1f" "\x59\x55\x7f\xcd\x61\xc0\x4b\x05\xb8\xcd\xc1\x48\xe9\xcd\x16\x1f"
"\x70\x15\x0c\xfc\xd3\x1a\x75\xd0\x93\x6c\xc4\xe0\x5c\xbe\xe2\x18" "\x70\x15\x0c\xfc\xd3\x1a\x75\xd0\x93\x6c\xc4\xe0\x5c\xbe\xe2\x18"
"\xc7\xaf\x72\xb6\x7c\x9b\x52"; "\xc7\xaf\x72\xb6\x7c\x9b\x52\x00";
sr_commit_t commit1, commit2; sr_commit_t commit1, commit2;
memcpy(commit1.encoded_commit, payload, sizeof(commit1.encoded_commit)); memcpy(commit1.encoded_commit, payload, sizeof(commit1.encoded_commit));
memcpy(commit2.encoded_commit, payload, sizeof(commit2.encoded_commit)); memcpy(commit2.encoded_commit, payload, sizeof(commit2.encoded_commit));