mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
hs: Ignore unparseable v3 introduction point
It is possible that at some point in time a client will encounter unknown or new fields for an introduction point in a descriptor so let them ignore it for forward compatibility. Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
f6df433b91
commit
82dee76740
@ -1747,18 +1747,13 @@ decode_introduction_point(const hs_descriptor_t *desc, const char *start)
|
|||||||
|
|
||||||
/* Given a descriptor string at <b>data</b>, decode all possible introduction
|
/* Given a descriptor string at <b>data</b>, decode all possible introduction
|
||||||
* points that we can find. Add the introduction point object to desc_enc as we
|
* points that we can find. Add the introduction point object to desc_enc as we
|
||||||
* find them. Return 0 on success.
|
* find them. This function can't fail and it is possible that zero
|
||||||
*
|
* introduction points can be decoded. */
|
||||||
* On error, a negative value is returned. It is possible that some intro
|
static void
|
||||||
* point object have been added to the desc_enc, they should be considered
|
|
||||||
* invalid. One single bad encoded introduction point will make this function
|
|
||||||
* return an error. */
|
|
||||||
STATIC int
|
|
||||||
decode_intro_points(const hs_descriptor_t *desc,
|
decode_intro_points(const hs_descriptor_t *desc,
|
||||||
hs_desc_encrypted_data_t *desc_enc,
|
hs_desc_encrypted_data_t *desc_enc,
|
||||||
const char *data)
|
const char *data)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
|
||||||
smartlist_t *chunked_desc = smartlist_new();
|
smartlist_t *chunked_desc = smartlist_new();
|
||||||
smartlist_t *intro_points = smartlist_new();
|
smartlist_t *intro_points = smartlist_new();
|
||||||
|
|
||||||
@ -1799,22 +1794,19 @@ decode_intro_points(const hs_descriptor_t *desc,
|
|||||||
SMARTLIST_FOREACH_BEGIN(intro_points, const char *, intro_point) {
|
SMARTLIST_FOREACH_BEGIN(intro_points, const char *, intro_point) {
|
||||||
hs_desc_intro_point_t *ip = decode_introduction_point(desc, intro_point);
|
hs_desc_intro_point_t *ip = decode_introduction_point(desc, intro_point);
|
||||||
if (!ip) {
|
if (!ip) {
|
||||||
/* Malformed introduction point section. Stop right away, this
|
/* Malformed introduction point section. We'll ignore this introduction
|
||||||
* descriptor shouldn't be used. */
|
* point and continue parsing. New or unknown fields are possible for
|
||||||
goto err;
|
* forward compatibility. */
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
smartlist_add(desc_enc->intro_points, ip);
|
smartlist_add(desc_enc->intro_points, ip);
|
||||||
} SMARTLIST_FOREACH_END(intro_point);
|
} SMARTLIST_FOREACH_END(intro_point);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
retval = 0;
|
|
||||||
|
|
||||||
err:
|
|
||||||
SMARTLIST_FOREACH(chunked_desc, char *, a, tor_free(a));
|
SMARTLIST_FOREACH(chunked_desc, char *, a, tor_free(a));
|
||||||
smartlist_free(chunked_desc);
|
smartlist_free(chunked_desc);
|
||||||
SMARTLIST_FOREACH(intro_points, char *, a, tor_free(a));
|
SMARTLIST_FOREACH(intro_points, char *, a, tor_free(a));
|
||||||
smartlist_free(intro_points);
|
smartlist_free(intro_points);
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
/* Return 1 iff the given base64 encoded signature in b64_sig from the encoded
|
/* Return 1 iff the given base64 encoded signature in b64_sig from the encoded
|
||||||
* descriptor in encoded_desc validates the descriptor content. */
|
* descriptor in encoded_desc validates the descriptor content. */
|
||||||
@ -2040,9 +2032,8 @@ desc_decode_encrypted_v3(const hs_descriptor_t *desc,
|
|||||||
/* Initialize the descriptor's introduction point list before we start
|
/* Initialize the descriptor's introduction point list before we start
|
||||||
* decoding. Having 0 intro point is valid. Then decode them all. */
|
* decoding. Having 0 intro point is valid. Then decode them all. */
|
||||||
desc_encrypted_out->intro_points = smartlist_new();
|
desc_encrypted_out->intro_points = smartlist_new();
|
||||||
if (decode_intro_points(desc, desc_encrypted_out, message) < 0) {
|
decode_intro_points(desc, desc_encrypted_out, message);
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
/* Validation of maximum introduction points allowed. */
|
/* Validation of maximum introduction points allowed. */
|
||||||
if (smartlist_len(desc_encrypted_out->intro_points) > MAX_INTRO_POINTS) {
|
if (smartlist_len(desc_encrypted_out->intro_points) > MAX_INTRO_POINTS) {
|
||||||
log_warn(LD_REND, "Service descriptor contains too many introduction "
|
log_warn(LD_REND, "Service descriptor contains too many introduction "
|
||||||
|
@ -223,9 +223,6 @@ STATIC smartlist_t *decode_link_specifiers(const char *encoded);
|
|||||||
STATIC hs_desc_intro_point_t *decode_introduction_point(
|
STATIC hs_desc_intro_point_t *decode_introduction_point(
|
||||||
const hs_descriptor_t *desc,
|
const hs_descriptor_t *desc,
|
||||||
const char *text);
|
const char *text);
|
||||||
STATIC int decode_intro_points(const hs_descriptor_t *desc,
|
|
||||||
hs_desc_encrypted_data_t *desc_enc,
|
|
||||||
const char *data);
|
|
||||||
STATIC int encrypted_data_length_is_valid(size_t len);
|
STATIC int encrypted_data_length_is_valid(size_t len);
|
||||||
STATIC int cert_is_valid(tor_cert_t *cert, uint8_t type,
|
STATIC int cert_is_valid(tor_cert_t *cert, uint8_t type,
|
||||||
const char *log_obj_type);
|
const char *log_obj_type);
|
||||||
|
Loading…
Reference in New Issue
Block a user