summaryrefslogtreecommitdiff
path: root/src/common/util.c
AgeCommit message (Collapse)Author
2016-05-12Merge branch 'maint-0.2.7' into maint-0.2.8Nick Mathewson
2016-05-12Merge branch 'bug18977_026_v2' into maint-0.2.7Nick Mathewson
2016-05-12Merge branch 'bug18977_024_v2' into bug18977_026_v2Nick Mathewson
Had conflicts related to other correct_tm bugs in 0.2.6. Added wday for another case.
2016-05-12Have correct_tm set tm_wday as well.Nick Mathewson
The tm_wday field had been left uninitialized, which was causing some assertions to fail on Windows unit tests. Fixes bug 18977.
2016-05-04Merge branch 'bug18686_025' into maint-0.2.8Nick Mathewson
2016-05-04Report success when not terminating an already terminated process.Nick Mathewson
Also, document the actual behavior and return values of tor_terminate_process. Fixes bug18686; bugfix on 0.2.3.9-alpha.
2016-03-25Only check in-boundsness of seconds when time_t is smaller than i64Nick Mathewson
Otherwise coverity complains that we're checking an whether an int64 is less than INT64_MIN, which of course it isn't. Fixes CID 1357176. Not in any released Tor.
2016-03-24Merge branch 'timegm_overflow_squashed'Nick Mathewson
2016-03-24Avoid overflow in tor_timegm on 32 bit platforms due to year 2038teor (Tim Wilson-Brown)
2016-03-22Fix an fd leak in check_private_dir().Nick Mathewson
The fd would leak when the User wasn't recogniezed by getpwnam(). Since we'd then go on to exit, this wasn't a terribad leak, but it's still not as nice as no leak at all. CID 1355640; bugfix on no released Tor.
2016-03-15Fix whitespace.Nick Mathewson
2016-03-15Merge remote-tracking branch 'weasel/bug18458'Nick Mathewson
2016-03-14When using open() to make sure we created a dir, close the fd afterwardsNick Mathewson
Found by coverity. Not in any released Tor. Fixes CID 1355640. Also, don't check for fd correctness with assert(fd). You need to assert (fd >= 0).
2016-03-01First RelaxDirModeCheck implementationPeter Palfrader
2016-02-27Update the copyright year.Nick Mathewson
2016-02-27Fix an unused-variable warningNick Mathewson
2016-02-25Fix check_private_dir() to work on Windows again.Nick Mathewson
On windows, you cannot open() a directory. So for Windows we should just take our previous stat-based approach. Closes bug 18392; bug not in any released Tor.
2016-02-23Appease make check-spacesAndrea Shepard
2016-02-16Merge branch 'bug17852_revised'Nick Mathewson
2016-02-16Harden check_private_dir() to remove any potential race.Jeremy
Remove any potential race between stat() and chmod(). Replace stat() with fstat(). Replace chmod() with fchmod()
2016-02-16src/common/util.c:expand_filename() - Perhaps use GetFullPathName() as a ↵Jeremy
form of input validation on the filename argument.
2015-12-15Replace usage of INLINE with inlinecypherpunks
This patch was generated using; sed -i -e "s/\bINLINE\b/inline/" src/*/*.[ch] src/*/*/*.[ch]
2015-12-10Permit filesystem group to be rootJamie Nguyen
2015-11-13appease check-spacesNick Mathewson
2015-11-12Merge branch 'karsten_bug13192_026_03_teor'Nick Mathewson
2015-11-12Rename cast_double_to_int64 to clamp_double_to_int64Nick Mathewson
2015-11-12Make round_to_next_multiple_of always round upwards.Nick Mathewson
Yes, even if it has to return a non-multiple. This prevents us from ever having a bug where we try to use it for allocation, and under-allocate.
2015-07-31Move formatting functions around.Nick Mathewson
The base64 and base32 functions used to be in crypto.c; crypto_format.h had no header; some general-purpose functions were in crypto_curve25519.c. This patch makes a {crypto,util}_format.[ch], and puts more functions there. Small modules are beautiful!
2015-07-27Allow a single trailing `.` when validating FQDNs from SOCKS.Yawning Angel
URI syntax (and DNS syntax) allows for a single trailing `.` to explicitly distinguish between a relative and absolute (fully-qualified) domain name. While this is redundant in that RFC 1928 DOMAINNAME addresses are *always* fully-qualified, certain clients blindly pass the trailing `.` along in the request. Fixes bug 16674; bugfix on 0.2.6.2-alpha.
2015-07-20Document the torrc format as thoroughly as possibleNick Mathewson
Closes ticket 2325
2015-07-16Fix most check-spaces issuesNick Mathewson
2015-07-15Add more EINVAL errno setting on key read failuresNick Mathewson
Teor found these. This is for part of #16582.
2015-07-14Make file-reading and key-reading preserve errnoNick Mathewson
This is an important part of #16582.
2015-06-24Work around nytimes.com's broken hostnames in our SOCKS checks.Yawning Angel
RFC 952 is approximately 30 years old, and people are failing to comply, by serving A records with '_' as part of the hostname. Since relaxing the check is a QOL improvement for our userbase, relax the check to allow such abominations as destinations, especially since there are likely to be other similarly misconfigured domains out there.
2015-05-07Merge branch 'writing_tests'Nick Mathewson
2015-05-07Write the outlines of a WritingTests.txt documentNick Mathewson
Also, add some sample tests to be examples.
2015-05-06Add an util function to cast double to int64_tDavid Goulet
Use it in the sample_laplace_distribution function to make sure we return the correct converted value after math operations are done on the input values. Thanks to Yawning for proposing a solution. Signed-off-by: David Goulet <dgoulet@ev0ke.net>
2015-05-06Tweak teor's and dgoulet's #13192 patches.Karsten Loesing
- Rewrite changes file. - Avoid float comparison with == and use <= instead. - Add teor's tor_llround(trunc(...)) back to silence clang warnings. - Replace tt_assert() with tt_i64_op() and friends. - Fix whitespace and a comment.
2015-05-06Handle edge cases in the round_*_to_next_multiple_of functionsteor
Consistently check for overflow in round_*_to_next_multiple_of. Check all round_*_to_next_multiple_of functions with expected values. Check all round_*_to_next_multiple_of functions with maximal values. Related to HS stats in #13192.
2015-05-06Handle edge cases in laplace functionsteor
Avoid division by zero. Avoid taking the log of zero. Silence clang type conversion warnings using round and trunc. The existing values returned by the laplace functions do not change. Add tests for laplace edge cases. These changes pass the existing unit tests without modification. Related to HS stats in #13192.
2015-04-02Fix the windows test failure caused by the #15435 changes.Yawning Angel
2015-04-01Merge remote-tracking branch 'yawning/feature15435'Nick Mathewson
2015-03-26Use prctl() to have the kernel SIGTERM background processes on exit.Yawning Angel
This uses a Linux-ism to attempt to always clean up background processes if possible. Note that it is not a catch-all, in that executables with suid/sgid or elevated capabilities will have the prctl() attribute stripped as part of the execve(). Resolves ticket 15471.
2015-03-26Implement "TOR_PT_EXIT_ON_STDIN_CLOSE".Yawning Angel
Background processes spawned by Tor now will have a valid stdin. Pluggable transports can detect this behavior with the aformentioned enviornment variable, and exit if stdin ever gets closed.
2015-02-17Remove tor_strclear(), and replace previous calls with memwipe().Yawning Angel
2015-01-28Bug #8405: Report SOCKS username/password in CIRC status eventsArthur Edelstein
Introduces two new circuit status name-value parameters: SOCKS_USERNAME and SOCKS_PASSWORD. Values are enclosing in quotes and unusual characters are escaped. Example: 650 CIRC 5 EXTENDED [...] SOCKS_USERNAME="my_username" SOCKS_PASSWORD="my_password"
2015-01-15Restrict sample values of the Laplace distribution to int64_t.George Kadianakis
This helps avoid undefined behavior from casting big double values to int64_t. Fixes #14090.
2015-01-12Merge remote-tracking branch 'teor/bug13111-empty-key-files-fn-empty'Nick Mathewson
2015-01-10Merge remote-tracking branch 'teor/fix-typos'Nick Mathewson
2015-01-10Merge branch 'master' of https://git.torproject.org/tor into ↵teor
bug13111-empty-key-files-fn-empty Conflicts: src/or/connection_edge.c Merged in favour of origin.