This would make the existing ‘PublishHidServDescriptors 0’ configuration option less useless, as well as making testing an implementation of some possible designs for #3507 (moved) much easier.
My malicious HSDir detection tool needs to be able to upload custom HS descriptors to a specific HSDir as defined by the HSDir's fingerprint. In the other use case, to create a hidden service load balancer [1] I would need to be able to upload a descriptor to its 3 responsible HSDir's.
For now it would be great to just be able to specific HSDir's, determining the responsible directorys can be offloaded to the client code without much difficulty.
Thanks for the review. I'm new to C, so apologies for all the rookie mistakes! I've attempted to fix the memory leaks that I can see. I've updated the code repo and also pushed a patch for the tor-spec.
"cp = (char*) body; don't cast off the const". This didn't seem right to me either. I was following the style of handle_control_postdescriptor(), where a '\0' is placed at the end of the argument list to stop argument parsing. As such a need a non const char pointer. What do you think I should do instead? Copy the argument line into a new char array and the parse the arguments from that instead?
Thanks for the review. I'm new to C, so apologies for all the rookie mistakes! I've attempted to fix the memory leaks that I can see. I've updated the code repo and also pushed a patch for the tor-spec.
No worries, thanks for the code.
"cp = (char*) body; don't cast off the const". This didn't seem right to me either. I was following the style of handle_control_postdescriptor(), where a '\0' is placed at the end of the argument list to stop argument parsing. As such a need a non const char pointer. What do you think I should do instead? Copy the argument line into a new char array and the parse the arguments from that instead?
Make sure I didn't mess anything up, and probably start seeking a 2nd reviewer (dgoulet maybe since he also has been doing control port stuff recently).
Make sure I didn't mess anything up, and probably start seeking a 2nd reviewer (dgoulet maybe since he also has been doing control port stuff recently).
I was reviewing but then you fixed the patch with the above so my review is a bit useless now ;). As for the memchr() and *cp++ = '\n' thingy, that's just plain bad. Assigning something to an originally const char pointer is not advise. Actually, if that memory was not in a writable section, you hit a big segfault. POSTDESCRIPTOR code should be fixed because this is very very bad practice.
The rest of the patch is fine. I'll have another look at the next revision :).
Here is my review of the tor-spec:
This will be problematic because parser and library expect HSAddress and AuthType even if none can be provided. This is why AuthType has a "NOAUTH" value and HSAddress, with #14847 (moved), will have a "UNKNOWN" value. Thus, I would suggest not putting them optional.
I was reviewing but then you fixed the patch with the above so my review is a bit useless now ;). As for the memchr() and *cp++ = '\n' thingy, that's just plain bad. Assigning something to an originally const char pointer is not advise. Actually, if that memory was not in a writable section, you hit a big segfault. POSTDESCRIPTOR code should be fixed because this is very very bad practice.
Yeah probably. Just tor_strdup() body or something, and make sure to free the copy on exit.
The rest of the patch is fine. I'll have another look at the next revision :).
Actually I screwed up.
The line that reads tor_free(desc); should be rend_encoded_v2_service_descriptor_free(desc);, since desc->desc_str needs to be cleaned up. The routine does the right thing on NULL, so a straight forward replacement is fine. A dumb mistake that I shouldn't make. :(