summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-04-25In control command api, rename "object" to "cmddata"Nick Mathewson
This makes it match control-spec.txt.
2019-04-25changes file for ticket 30091 (controller parsing refactor)Nick Mathewson
2019-04-25expand CMD_FL_WIPE to wipe the parsed arguments tooNick Mathewson
2019-04-25Simplify handler logic in control_cmd.cNick Mathewson
Now that the legacy handlers are gone, we can simplify the structures and macros here.
2019-04-25Port the authenticate and authchallenge commands to the new parserNick Mathewson
These two presented their own challenge, because of their use of QString, and their distinguished handling of quoted versus non-quoted values.
2019-04-25Add rudimentary qstring support to kvline.cNick Mathewson
2019-04-25Move and rename decode_escaped_string()Nick Mathewson
This function decodes something different from the usual c-escaped format. It is only used in controller authorization.
2019-04-25Use the new controller command parser for EXTENDCIRCUIT.Nick Mathewson
This command does not fit perfectly with the others, since its second argument is optional and may contain equal signs. Still, it's probably better to squeeze it into the new metaformat, since doing so allows us to remove several pieces of the old command-parsing machinery.
2019-04-25Use new parser logic for SETCONF/RESETCONF code.Nick Mathewson
Here we get to throw away a LOT of unused code, since most of the old parsing was redundant with kvline.
2019-04-25Update more controller commands, now that we have kvline supportNick Mathewson
2019-04-25Add a case-insensitive variant to config_line_find()Nick Mathewson
2019-04-25Add kvline support to controller command parser.Nick Mathewson
This should let us handle all (or nearly all) of the remaining commands.
2019-04-25Allow kvlines in control commands.Nick Mathewson
2019-04-25Add fuzzing support for several more groups of kvlines flagsNick Mathewson
2019-04-25kvline: handle empty alues as well as empty keysNick Mathewson
The two options are mutually exclusive, since otherwise an entry like "Foo" would be ambiguous. We want to have the ability to treat entries like this as keys, though, since some controller commands interpret them as flags.
2019-04-25Use parsing code for the simpler controller commands.Nick Mathewson
(This should be all of the command that work nicely with positional arguments only.) Some of these commands should probably treat extra arguments as incorrect, but for now I'm trying to be careful not to break any existing users.
2019-04-25Unit tests for current control-command parser logicNick Mathewson
2019-04-25When parsing a multiline controller command, be careful with linebreaksNick Mathewson
The first line break in particular was mishandled: it was discarded if no arguments came before it, which made it impossible to distinguish arguments from the first line of the body. To solve this, we need to allocate a copy of the command rather than using NUL to separate it, since we might have "COMMAND\n" as our input. Fixes ticket 29984.
2019-04-25Extract the argument-splitting part of control.c's parserNick Mathewson
This is preliminary work for fixing 29984; no behavior has changed.
2019-04-25Start on a command-parsing tool for controller commands.Nick Mathewson
There _is_ an underlying logic to these commands, but it isn't wholly uniform, given years of tweaks and changes. Fortunately I think there is a superset that will work. This commit adds a parser for some of the most basic cases -- the ones currently handled by getargs_helper() and some of the object-taking ones. Soon will come initial tests; then I'll start using the parser. After that, I'll expand the parser to handle the other cases that come up in the controller protocol.
2019-04-12Define two more commands as wipe-after-parse.Nick Mathewson
2019-04-12Add assertions for correct input to handle_control_command.Nick Mathewson
2019-04-12Improve handling of controller commandsNick Mathewson
Use a table-based lookup to find the right command handler. This will serve as the basement for several future improvements, as we improve the API for parsing commands.
2019-04-12Merge branch 'tor-github/pr/908'George Kadianakis
2019-04-12Merge branch 'tor-github/pr/754'George Kadianakis
2019-04-12crypt_ops: Stop using a separate buffer in ed25519_signature_from_base64()teor
Part of 29960.
2019-04-11forward-port the 0.4.0.4-rc changelogNick Mathewson
2019-04-11Merge branch 'maint-0.4.0'Nick Mathewson
2019-04-11bump to 0.4.0.4-rc-devNick Mathewson
2019-04-11Merge remote-tracking branch 'tor-github/pr/913'Nick Mathewson
2019-04-11Merge remote-tracking branch 'tor-github/pr/887'Nick Mathewson
2019-04-11Merge remote-tracking branch 'tor-github/pr/741'Nick Mathewson
2019-04-10Merge branch 'maint-0.4.0'Nick Mathewson
2019-04-10Bump version to 0.4.0.4-rcNick Mathewson
2019-04-10Merge branch 'maint-0.4.0'Nick Mathewson
2019-04-10Merge remote-tracking branch 'tor-github/pr/926' into maint-0.4.0Nick Mathewson
2019-04-10Add changes file for #30040.George Kadianakis
2019-04-10Prevent double free on huge files with 32 bit.Tobias Stoeckmann
The function compat_getdelim_ is used for tor_getline if tor is compiled on a system that lacks getline and getdelim. These systems should be very rare, considering that getdelim is POSIX. If this system is further a 32 bit architecture, it is possible to trigger a double free with huge files. If bufsiz has been already increased to 2 GB, the next chunk would be 4 GB in size, which wraps around to 0 due to 32 bit limitations. A realloc(*buf, 0) could be imagined as "free(*buf); return malloc(0);" which therefore could return NULL. The code in question considers that an error, but will keep the value of *buf pointing to already freed memory. The caller of tor_getline() would free the pointer again, therefore leading to a double free. This code can only be triggered in dirserv_read_measured_bandwidths with a huge measured bandwith list file on a system that actually allows to reach 2 GB of space through realloc. It is not possible to trigger this on Linux with glibc or other major *BSD systems even on unit tests, because these systems cannot reach so much memory due to memory fragmentation. This patch is effectively based on the penetration test report of cure53 for curl available at https://cure53.de/pentest-report_curl.pdf and explained under section "CRL-01-007 Double-free in aprintf() via unsafe size_t multiplication (Medium)".
2019-04-10practracker: accept 4 extra lines due to 30041teor
2019-04-10Merge branch 'maint-0.4.0'teor
2019-04-10Merge remote-tracking branch 'tor-github/pr/920' into maint-0.4.0teor
2019-04-09Merge branch 'maint-0.4.0'Nick Mathewson
2019-04-09Merge branch 'bug29922_035' into maint-0.4.0Nick Mathewson
2019-04-09Actually I believe this should be an EINVAL.Nick Mathewson
2019-04-09Changes file for bug30041Nick Mathewson
2019-04-09Check return value of buf_move_to_buf for error.Tobias Stoeckmann
If the concatenation of connection buffer and the buffer of linked connection exceeds INT_MAX bytes, then buf_move_to_buf returns -1 as an error value. This value is currently casted to size_t (variable n_read) and will erroneously lead to an increasement of variable "max_to_read". This in turn can be used to call connection_buf_read_from_socket to store more data inside the buffer than expected and clogging the connection buffer. If the linked connection buffer was able to overflow INT_MAX, the call of buf_move_to_buf would have previously internally triggered an integer overflow, corrupting the state of the connection buffer. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-04-09Protect buffers against INT_MAX datalen overflows.Tobias Stoeckmann
Many buffer functions have a hard limit of INT_MAX for datalen, but this limitation is not enforced in all functions: - buf_move_all may exceed that limit with too many chunks - buf_move_to_buf exceeds that limit with invalid buf_flushlen argument - buf_new_with_data may exceed that limit (unit tests only) This patch adds some annotations in some buf_pos_t functions to guarantee that no out of boundary access could occur even if another function lacks safe guards against datalen overflows. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2019-04-09Merge branch 'maint-0.4.0'George Kadianakis
2019-04-09Merge branch 'tor-github/pr/915' into maint-0.4.0George Kadianakis
2019-04-09Merge branch 'maint-0.4.0'teor