summaryrefslogtreecommitdiff
path: root/src/common/compat.c
AgeCommit message (Collapse)Author
2010-04-19Fix two compile-blockers in tor_vasprintf().Nick Mathewson
1) mingw doesn't have _vscprintf(); mingw instead has a working snprintf. 2) windows compilers that _do_ have a working _vscprintf spell it so; they do not spell it _vcsprintf().
2010-04-02Merge branch 'asprintf'Nick Mathewson
2010-02-28better handle the case where *strp is in asprintf argsNick Mathewson
2010-02-27Merge remote branch 'origin/maint-0.2.1'Nick Mathewson
Conflicts: src/common/test.h src/or/test.c
2010-02-27Update Tor Project copyright yearsNick Mathewson
2010-02-25Add a tor_asprintf() function, and use it in a couple of places.Nick Mathewson
asprintf() is a GNU extension that some BSDs have picked up: it does a printf into a newly allocated chunk of RAM. Our tor_asprintf() differs from standard asprintf() in that: - Like our other malloc functions, it asserts on OOM. - It works on windows. - It always sets its return-field.
2010-02-22Remove misc unnecessary newlines found by new check.Mike Perry
2010-02-12Remove the --enable-iphone option as needless.Nick Mathewson
On or-talk, Marco Bonetti reports that recent iPhone SDKs build Tor fine without it.
2010-02-10Add Windows version detection for Vista and 7Sebastian Hahn
Vista is Windows 6.0, and 7 is Windows 6.1. Fixes bug 1097. Also fix a coding style violation.
2010-01-19Fix build on Solaris by disabling support for DisableAllSwapSebastian Hahn
Fixes bug 1198. Solaris doesn't have RLIMIT_MEMLOCK for get/setrlimit, so disable support because we don't know if all memory can be locked.
2010-01-15don't list windows capabilities in windows unameRoger Dingledine
we never used them, and maybe it's a bad idea to publish them
2009-12-12*_free functions now accept NULLSebastian Hahn
Some *_free functions threw asserts when passed NULL. Now all of them accept NULL as input and perform no action when called that way. This gains us consistence for our free functions, and allows some code simplifications where an explicit null check is no longer necessary.
2009-11-20Use the same mlockall checks with tor_set_max_memlockNick Mathewson
2009-11-20Fix compilation on OSX 10.3.Nick Mathewson
On this OSX version, there is a stub mlockall() function that doesn't work, *and* the declaration for it is hidden by an '#ifdef _P1003_1B_VISIBLE'. This would make autoconf successfully find the function, but our code fail to build when no declaration was found. This patch adds an additional test for the declaration.
2009-11-14Fix compilation with with bionic libc.Jacob Appelbaum
This fixes bug 1147: bionic doesn't have an actual implementation of mlockall(); mlockall() is merely in the headers but not actually in the library. This prevents Tor compilation with the bionic libc for Android handsets.
2009-10-27Implement DisableAllSwap to avoid putting secret info in page files.Jacob Appelbaum
This commit implements a new config option: 'DisableAllSwap' This option probably only works properly when Tor is started as root. We added two new functions: tor_mlockall() and tor_set_max_memlock(). tor_mlockall() attempts to mlock() all current and all future memory pages. For tor_mlockall() to work properly we set the process rlimits for memory to RLIM_INFINITY (and beyond) inside of tor_set_max_memlock(). We behave differently from mlockall() by only allowing tor_mlockall() to be called one single time. All other calls will result in a return code of 1. It is not possible to change DisableAllSwap while running. A sample configuration item was added to the torrc.complete.in config file. A new item in the man page for DisableAllSwap was added. Thanks to Moxie Marlinspike and Chris Palmer for their feedback on this patch. Please note that we make no guarantees about the quality of your OS and its mlock/mlockall implementation. It is possible that this will do nothing at all. It is also possible that you can ulimit the mlock properties of a given user such that root is not required. This has not been extensively tested and is unsupported. I have included some comments for possible ways we can handle this on win32.
2009-09-15some cleanups:Sebastian Hahn
documentation fix for get_uint64 remove extra "." from a log line fix a long line
2009-08-09Add a new tor_strtok_r for platforms that don't have one, plus tests.Nick Mathewson
I don't think we actually use (or plan to use) strtok_r in a reentrant way anywhere in our code, but would be nice not to have to think about whether we're doing it.
2009-05-30Don't attempt to log messages to a controller from a worker thread.Nick Mathewson
This patch adds a function to determine whether we're in the main thread, and changes control_event_logmsg() to return immediately if we're in a subthread. This is necessary because otherwise we will call connection_write_to_buf, which modifies non-locked data structures. Bugfix on 0.2.0.x; fix for at least one of the things currently called "bug 977".
2009-05-27Spell-check Tor.Nick Mathewson
2009-05-13Use a mutex to protect the count of open sockets.Nick Mathewson
This matters because a cpuworker can close its socket when it finishes. Cpuworker typically runs in another thread, so without a lock here, we can have a race condition and get confused about how many sockets are open. Possible fix for bug 939.
2009-05-04Update copyright to 2009.Karsten Loesing
2009-03-03Actually use tor_sscanf() to parse untrusted input.Nick Mathewson
svn:r18761
2009-03-02Add and use set/get_uint64 on onion tags. [bug 604; backportable]Nick Mathewson
It seems that 64-bit Sparc Solaris demands 64-bit-aligned access to uint64_t, but does not 64-bit-align the stack-allocated char array we use for cpuworker tags. So this patch adds a set/get_uint64 pair, and uses them to access the conn_id field in the tag. svn:r18743
2009-02-09Use prctl to reenable core dumps when we have setuid to a non-root user.Nick Mathewson
svn:r18449
2009-02-09Remove some deadcode and use tor_inet_aton uniformly.Nick Mathewson
svn:r18422
2009-01-21Fix warning on panther compile, and bug 913. Backport candidate.Nick Mathewson
svn:r18203
2009-01-20Add a better (non-locale-having) ctypes implementation to avoid protocol and ↵Nick Mathewson
parsing mismatches on different platforms. svn:r18189
2009-01-04Fix the oldest bug in a while: stop accepting 1.2.3 as a valid IPv4 address ↵Nick Mathewson
on any platform. svn:r17887
2009-01-04Remove svn $Id$s from our source, and remove tor --version --version.Nick Mathewson
The subversion $Id$ fields made every commit force a rebuild of whatever file got committed. They were not actually useful for telling the version of Tor files in the wild. svn:r17867
2008-12-30Remove some code that is #ifdefed out, and that we no longer seem to use, if ↵Nick Mathewson
we ever did. svn:r17827
2008-12-22Make freelist_len in memarea.c static; document a few variables.Nick Mathewson
svn:r17741
2008-12-22Add DOCDOC entries for undocumented static and global variables.Nick Mathewson
svn:r17739
2008-12-22Fix most DOCDOCs remaining and/or added by redox.Nick Mathewson
svn:r17734
2008-12-22Add DOCDOC comments for all undocumented functions. Add missing *s to other ↵Nick Mathewson
comments so that they will get recognized as doxygen. svn:r17729
2008-12-11Lower sprintf buffer max to ~SSIZE_T_MAX from SIZE_T_CEILING, since we need ↵Nick Mathewson
to compare it to a signed int. svn:r17600
2008-12-09Better error message when told to setuid to ourself.Nick Mathewson
svn:r17543
2008-12-08Compile without warnings on mingw.tor-0.2.1.8-alphaNick Mathewson
svn:r17522
2008-12-05Try to fix windows mmap code.Nick Mathewson
svn:r17493
2008-12-05Simplify mmap object layout to avoid confusing static analysis tools, and us ↵Nick Mathewson
too. svn:r17490
2008-12-05Fix a hard-to-trigger memory leak in log_credential status. Found by ↵Nick Mathewson
Coverity scan. CID 349. svn:r17484
2008-12-02style cleanupRoger Dingledine
svn:r17457
2008-12-02Add two lseek wrappers to compat.[ch]: one to return current fd position, ↵Nick Mathewson
and one to move the fd to the end of the file. svn:r17454
2008-11-26Cast uid_t and gid_t to unsigned before passing to printf %u.Nick Mathewson
svn:r17392
2008-11-26Use fcntl for file locking when flock() is not available.Nick Mathewson
svn:r17391
2008-11-11apply sebastian's fix for bug 859. Apparently on win32 one must lock at ↵Nick Mathewson
least one byte when locking, but locking a nonexistant byte is okay. ) svn:r17244
2008-11-10Document a couple of functions.Nick Mathewson
svn:r17239
2008-11-10beg nick for some documentation on the locking functionsRoger Dingledine
svn:r17233
2008-11-10better error message when you set User but start tor as non-root.Roger Dingledine
hopefully will address bug 857. svn:r17232
2008-11-09Log a little more when credential-switching fails.Nick Mathewson
svn:r17228