aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
Commit message (Collapse)AuthorAge
* Merge branch '6044_nm_squashed'Nick Mathewson2012-09-17
|\
| * Handle FIFOs in read_file_to_strmeejah2012-09-17
| | | | | | | | | | | | | | | | add read_file_to_str_until_eof which is used by read_file_to_str if the file happens to be a FIFO. change file_status() to return FN_FILE if st_mode matches S_IFIFO (on not-windows) so that init_key_from_file() will read from a FIFO.
* | Merge remote-tracking branch 'origin/maint-0.2.3'Nick Mathewson2012-09-14
|\ \
| * | Use file-size-fixup code on cygwin too.Nick Mathewson2012-09-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | We already had code on windows to fix our file sizes when we're reading a file in text mode and its size doesn't match the size from fstat. But that code was only enabled when _WIN32 was defined, and Cygwin defines __CYGWIN__ instead. Fixes bug 6844; bugfix on 0.1.2.7-alpha.
* | | Fix compilation with older gccsNick Mathewson2012-09-14
| | | | | | | | | | | | | | | | | | | | | | | | They don't like to have #preprocessor directives inside macro arguments. Fixes #6842; fix on 0.2.4.2-alpha. Found by grarpamp.
* | | Don't compute ((uint64_t)1)<<64 in round_to_power_of_2Nick Mathewson2012-09-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This would be undefined behavior if it happened. (It can't actually happen as we're using round_to_power_of_2, since we would have to be trying to allocate exabytes of data.) While we're at it, fix the behavior of round_to_power_of_2(0), and document the function better. Fix for bug 6831.
* | | hot: we fixed incancations to be intancations.Roger Dingledine2012-09-12
| | |
* | | Merge remote-tracking branch 'public/bug6538'Nick Mathewson2012-09-11
|\ \ \ | | | | | | | | | | | | | | | | Conflicts: configure.ac
| * | | Spelling fix in util.c commentsNick Mathewson2012-08-27
| | | |
| * | | Change smartlist_choose_node_by_bandwidth to avoid doubleNick Mathewson2012-08-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should make our preferred solution to #6538 easier to implement, avoid a bunch of potential nastiness with excessive int-vs-double math, and generally make the code there a little less scary. "But wait!" you say. "Is it really safe to do this? Won't the results come out differently?" Yes, but not much. We now round every weighted bandwidth to the nearest byte before computing on it. This will make every node that had a fractional part of its weighted bandwidth before either slighty more likely or slightly less likely. Further, the rand_bw value was only ever set with integer precision, so it can't accurately sample routers with tiny fractional bandwidth values anyway. Finally, doing repeated double-vs-uint64 comparisons is just plain sad; it will involve an implicit cast to double, which is never a fun thing.
* | | | Merge remote-tracking branch 'origin/maint-0.2.3'Nick Mathewson2012-09-11
|\ \ \ \ | | |/ / | |/| / | |_|/ |/| |
| * | Merge remote-tracking branch 'origin/maint-0.2.2' into maint-0.2.3Nick Mathewson2012-09-11
| |\ \ | | |/ | |/| | | | | | | Conflicts: src/test/test_util.c
| | * Fix assertion failure in tor_timegm.Nick Mathewson2012-09-11
| | | | | | | | | | | | Fixes bug 6811.
* | | Merge remote-tracking branch 'asn/bug4567_rebased'Nick Mathewson2012-09-06
|\ \ \
| * | | Fix some bugs that did not allow compilation on Windows.George Kadianakis2012-09-05
| | | |
| * | | General tweaks and fixes for Nick's comments.George Kadianakis2012-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add changes/ files. * Edit the tor-fw-helper manpage. * Fix check-spaces. * Add prototype for get_list_of_ports_to_forward(). * Fix tor_parse_long() TCP port range. * Improve doc. of tor_check_port_forwarding(). * Check for overflows in tor_check_port_forwarding(). * Demote successful port forwarding to LOG_INFO. Conflicts: src/common/address.c src/or/circuitbuild.c
| * | | Refactor tor to support the new tor-fw-helper protocol.George Kadianakis2012-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add handle_fw_helper_output(), a function responsible for parsing the output of tor-fw-helper. Refactor tor_check_port_forwarding() and run_scheduled_events() accordingly too. We now issue warnings when we get control output from tor-fw-helper, and we log the verbose output of tor-fw-helper in LOG_INFO. Conflicts: src/common/util.c
| * | | Introduce get_lines_from_handle().George Kadianakis2012-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | get_lines_from_handle() is a multiplatform function which drains lines from a stream and stuffs it into a smartlist. It's useful for line-based protocols, like the one managed proxy and the tor-fw-helper protocols.
* | | | Log more information when we fail to terminate a process.George Kadianakis2012-09-06
|/ / /
* | | Remove tor_malloc_roundup().Nick Mathewson2012-08-13
| | | | | | | | | | | | | | | This function never actually did us any good, and it added a little complexity. See the changes file for more info.
* | | Fix clang warning on d4285f03df475dc. Not in any released tor.Nick Mathewson2012-06-29
| | |
* | | Merge commit '81cd3d7ad641a8dbf'Nick Mathewson2012-06-28
|\| |
| * | add a blurb for 0.2.3.18-rc, other minor cleanupsRoger Dingledine2012-06-28
| | |
* | | Extend tor_sscanf so it can replace sscanf in rephist.cNick Mathewson2012-06-28
| | | | | | | | | | | | Fixes bug 4195 and Coverity CID 448
* | | Merge remote-tracking branch 'origin/maint-0.2.3'Nick Mathewson2012-06-26
|\| |
| * | Fix a warning when using glibc's strcspn with clang.Nick Mathewson2012-06-26
| | | | | | | | | | | | | | | | | | | | | | | | With glibc 2.15 and clang 3.0, I get warnings from where we use the strcpsn implementation in the header as strcspn(string, "="). This is apparently because clang sees that part of the strcspn macro expands to "="[2], and doesn't realize that that part of the macro is only evaluated when "="[1] != 0.
| * | Fix a compilation warning with clang 3.0Nick Mathewson2012-06-26
| | | | | | | | | | | | | | | | | | | | | In b1ad1a1d0266a20bb we introduced an implicit (but safe) long-to-int shortening that clang didn't like. Warning not in any released version of Tor.
* | | Merge remote-tracking branch 'public/bug2385'Nick Mathewson2012-06-25
|\ \ \ | |/ / |/| |
| * | Clear a couple more fields in rend_service_load_auth_keysNick Mathewson2012-06-18
| | |
* | | Don't assert in get_string_from_pipe() on len==0Nick Mathewson2012-06-23
| | | | | | | | | | | | | | | | | | | | | We can treat this case as an EAGAIN (probably because of an unexpected internal NUL) rather than a crash-worthy problem. Fixes bug 6225, again. Bug not in any released version of Tor.
* | | Resolve crash caused by format_helper_exit_status changes in #5557Nick Mathewson2012-06-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Because the string output was no longer equal in length to HEX_ERRNO_SIZE, the write() call would add some extra spaces and maybe a NUL, and the NUL would trigger an assert in get_string_from_pipe. Fixes bug 6225; bug not in any released version of Tor.
* | | Style tweaks and add a warning about NUL-terminationNick Mathewson2012-06-22
| | |
* | | Refactor unsigned int hex formatting out of format_helper_exit_status() in ↵Andrea Shepard2012-06-22
| | | | | | | | | | | | util.c
* | | Make format_helper_exit_status() avoid unnecessary spacesAndrea Shepard2012-06-22
|/ /
* | Fix mingw build with -DUNICODE -D_UNICODENick Mathewson2012-06-07
| | | | | | | | | | This is a very blunt fix, and mostly just turns some func() calls into FuncA() to make things build again. Fixes bug 6097.
* | Be more careful calling wcstombsNick Mathewson2012-06-07
| | | | | | | | | | | | | | | | | | | | | | The function is not guaranteed to NUL-terminate its output. It *is*, however, guaranteed not to generate more than two bytes per multibyte character (plus terminating nul), so the general approach I'm taking is to try to allocate enough space, AND to manually add a NUL at the end of each buffer just in case I screwed up the "enough space" thing. Fixes bug 5909.
* | Fix some mingw build warningsNick Mathewson2012-06-05
| | | | | | | | | | | | | | | | These include: - Having a weird in_addr that can't be initialized with {0} - Needing INVALID_HANDLE_VALUE instead of -1 for file handles. - Having a weird dependent definition for struct stat. - pid is signed, not unsigned.
* | Merge remote-tracking branch 'public/bug3894'Nick Mathewson2012-06-05
|\ \
| * | Fix some more FreeBSD4 issues (based on a patch from grarpamp)Nick Mathewson2012-05-16
| |/ | | | | | | | | | | | | Apparently, freebsd 4 doesn't like malloc.h, needs sys/param.h for MIN/MAX, and doesn't have a SIZE_MAX. For bug 3894.
* | Update copyright dates to 2012; add a few missing copyright statementsNick Mathewson2012-06-04
| |
* | Add about 60 more DOCDOC comments to 0.2.3Nick Mathewson2012-06-04
| | | | | | | | | | | | | | | | Also, try to resolve some doxygen issues. First, define a magic "This is doxygen!" macro so that we take the correct branch in various #if/#else/#endifs in order to get the right documentation. Second, add in a few grouping @{ and @} entries in order to get some variables and fields to get grouped together.
* | Resolve all currently pending DOCDOC items in masterNick Mathewson2012-06-04
| |
* | Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson2012-05-16
|\|
| * Fix month check in parse_http_time, add testSebastian Hahn2012-05-16
| |
| * Remove more dubiosity in struct tm handling. related to bug5346Nick Mathewson2012-05-16
| |
| * Reject an additional type of bad date in parse_http_timeNick Mathewson2012-05-16
| |
| * Fix parse_http_time and add testsEsteban Manchado Velázquez2012-05-16
| | | | | | | | | | | | | | | | * It seems parse_http_time wasn't parsing correctly any date with commas (RFCs 1123 and 850). Fix that. * It seems parse_http_time was reporting the wrong month (they start at 0, not 1). Fix that. * Add some tests for parse_http_time, covering all three formats.
* | Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson2012-05-10
|\| | | | | | | | | | | Conflicts: src/common/util.c src/test/test_util.c
| * Handle out-of-range values in tor_parse_* integer functionsNick Mathewson2012-05-07
| | | | | | | | | | | | | | | | | | | | | | The underlying strtoX functions handle overflow by saturating and setting errno to ERANGE. If the min/max arguments to the tor_parse_* functions are equal to the minimum/maximum of the underlying type, then with the old approach, we wouldn't treat a too-large value as genuinely broken. Found this while looking at bug 5786; bugfix on 19da1f36 (in Tor 0.0.9), which introduced these functions.
* | Several mingw/msvc/cross-compilation fixesNick Mathewson2012-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | They boil down to: - MS_WINDOWS is dead and replaced with _WIN32, but we let a few instances creep in when we merged Esteban's tests. - Capitalizing windows header names confuses mingw. - #ifdef 0 ain't C. - One unit test wasn't compiled on windows, but was being listed anyway. - One unit test was checking for the wrong value. Gisle Vanem found and fixed the latter 3 issues.