diff options
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r-- | src/or/rendcommon.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 95d16f1362..49827459be 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -919,6 +919,24 @@ rend_valid_service_id(const char *query) return 1; } +/** Return true iff <b>query</b> is a syntactically valid descriptor ID. + * (as generated by rend_get_descriptor_id_bytes). */ +int +rend_valid_descriptor_id(const char *query) +{ + if (strlen(query) != REND_DESC_ID_V2_LEN_BASE32) { + goto invalid; + } + if (strspn(query, BASE32_CHARS) != REND_DESC_ID_V2_LEN_BASE32) { + goto invalid; + } + + return 1; + +invalid: + return 0; +} + /** Lookup in the client cache the given service ID <b>query</b> for * <b>version</b>. * |