summaryrefslogtreecommitdiff
path: root/src/common/compat.c
AgeCommit message (Collapse)Author
2014-10-23Fix minor typos, two line lengths, and a repeated includeteor
2014-10-20Clamp (some) years supplied by the system to 1 CEteor
Clamp year values returned by system localtime(_r) and gmtime(_r) to year 1. This ensures tor can read any values it might write out. Fixes bug 13476.
2014-10-20Use correct day of year in correct_tm()teor
Set the correct day of year value in correct_tm() when the system's localtime(_r) or gmtime(_r) functions fail to set struct tm. Fixes bug 13476.
2014-09-09Use S?SIZE_MAX, not S?SIZE_T_MAXNick Mathewson
This fixes bug 13102 (not on any released Tor) where using the standard SSIZE_MAX name broke mingw64, and we didn't realize. I did this with perl -i -pe 's/SIZE_T_MAX/SIZE_MAX/' src/*/*.[ch] src/*/*/*.[ch]
2014-09-02Explicitly initialize addresses in tor_ersatz_socketpairNick Mathewson
This should stop a false positive from the clangalyzer.
2014-08-20Fix return value of tor_fd_seekend.Nick Mathewson
Previously, we had documented it to return -1 or 0, when in fact lseek returns -1 or the new position in the file. This is harmless, since we were only checking for negative values when we used tor_fd_seekend.
2014-08-20Allow named pipes for our log files.Nick Mathewson
Closes ticket 12061. Based on a patch from "carlo von lynX" on tor-dev at https://lists.torproject.org/pipermail/tor-dev/2014-April/006705.html
2014-08-13Apply coccinelle script to replace malloc(a*b)->calloc(a,b)Nick Mathewson
2014-07-16Add a tor_ftruncate to replace ftruncate.Nick Mathewson
(Windows doesn't have ftruncate, and some ftruncates do not move the file pointer to the start of the file.)
2014-06-20Thread support is now requiredNick Mathewson
Long ago we supported systems where there was no support for threads, or where the threading library was broken. We shouldn't have do that any more: on every OS that matters, threads exist, and the OS supports running threads across multiple CPUs. This resolves tickets 9495 and 12439. It's a prerequisite to making our workqueue code work better, since sensible workqueue implementations don't split across multiple processes.
2014-06-20Remove code for Windows CE supportNick Mathewson
As far as I know, nobody has used this in ages. It would be a pretty big surprise if it had worked. Closes ticket 11446.
2014-06-14Merge branch 'bug8746_v2_squashed'Nick Mathewson
Conflicts: src/common/include.am
2014-06-14New testing-only tor_sleep_msec functionNick Mathewson
In the unit tests I want to loop with a delay, but I want less than a 1 second delay. This, sadly, requires compatibility code.
2014-05-14whitespace fix, moreNick Mathewson
2014-05-14Improved comments on bug11946 fixNick Mathewson
2014-05-14Use tor_getpw{nam,uid} wrappers to fix bug 11946Nick Mathewson
When running with User set, we frequently try to look up our information in the user database (e.g., /etc/passwd). The seccomp2 sandbox setup doesn't let us open /etc/passwd, and probably shouldn't. To fix this, we have a pair of wrappers for getpwnam and getpwuid. When a real call to getpwnam or getpwuid fails, they fall back to a cached value, if the uid/gid matches. (Granting access to /etc/passwd isn't possible with the way we handle opening files through the sandbox. It's not desirable either.)
2014-05-14Add a pair of wrapper functions: tor_getpwnam() and tor_getpwuid()Nick Mathewson
We'll use these to deal with being unable to access the user DB after we install the sandbox, to fix bug 11946.
2014-05-08Return success when get_total_system_memory() succeeds.Nick Mathewson
Fixes bug 11805; bugfix on 0.2.5.4-alpha.
2014-05-01Merge remote-tracking branch 'public/bug4345a_024'Nick Mathewson
2014-04-25Merge branch 'scanbuild_fixes'Nick Mathewson
2014-04-24Merge branch 'bug11396_v2_squashed'Nick Mathewson
Conflicts: src/or/main.c
2014-04-24get_total_system_memory(): see how much RAM we haveNick Mathewson
2014-04-19scan-build: avoid undef behaior in tor_inet_ptonNick Mathewson
If we had an address of the form "1.2.3.4" and we tried to pass it to tor_inet_pton with AF_INET6, it was possible for our 'eow' pointer to briefly move backwards to the point before the start of the string, before we moved it right back to the start of the string. C doesn't allow that, and though we haven't yet hit a compiler that decided to nuke us in response, it's best to fix. So, be more explicit about requiring there to be a : before any IPv4 address part of the IPv6 address. We would have rejected addresses without a : for not being IPv6 later on anyway.
2014-04-16Make sure everything using an interned string is preceded by a logNick Mathewson
(It's nice to know what we were about to rename before we died from renaming it.)
2014-04-16Add 'rename' to the sandboxed syscallsNick Mathewson
(If we don't restrict rename, there's not much point in restricting open, since an attacker could always use rename to make us open whatever they want.)
2014-04-07Merge remote-tracking branch 'public/bug10363_024_squashed'Nick Mathewson
2014-04-07Another 10363 instance: this one in tor_memmem fallback codeNick Mathewson
2014-03-31Handle tor_munmap_file(NULL) consistentlyNick Mathewson
2014-03-31Eliminate lseek() with unchecked return in tor_mmap_file()Andrea Shepard
2014-03-31Add return value and assert for null parameter to tor_munmap_file()Andrea Shepard
2014-02-07More hacking around spawn_func issuesNick Mathewson
This time, we use a pthread_attr to make sure that if pthread_create succeeds, the thread is successfully detached. This probably isn't the big thing going on with 4345, since it'd be a bit weird for pthread_detach to be failing. But it's worth getting it right.
2013-09-13Merge remote-tracking branch 'ctoader/gsoc-cap-stage2'Nick Mathewson
Conflicts: src/common/sandbox.c
2013-09-03Merge remote-tracking branch 'origin/maint-0.2.4'Nick Mathewson
2013-09-03Avoid a double-close on one failing case of the socketpair replacement codeNick Mathewson
Fix for bug 9400, spotted by coverity. Bug introduced in revision 2cb4f7a4 (subversion revision r389).
2013-08-15added comments for sandbox.hCristian Toader
2013-08-06Use SOCKET_OK/TOR_INVALID_SOCKET in socketpair replacement codeNick Mathewson
2013-08-02Fixed "unused parameter cloexec" warnings on windowsNick Mathewson
2013-08-02Split the socketpair replacement code into its own function for testingNick Mathewson
2013-08-02Actually use the cloexec argument in the !defined(SOCK_CLOEXEC) caseNick Mathewson
2013-08-02Prepare patch for ticket 5129 for merging.Peter Retzlaff
- Preserve old eventdns code. - Add function to close sockets cross-platform, without accounting. - Add changes/ file.
2013-07-29Changes as suggested by nickmCristian Toader
- char* to const char* and name refactoring - workaround for accept4 syscall
2013-07-23added experimental support for open syscall path paramCristian Toader
2013-07-15Fix two pre-coffee typosPeter Palfrader
2013-07-15Document get_parent_directory morePeter Palfrader
2013-06-13Define SEEK_SET for platforms that lack it.Nick Mathewson
2013-06-13If we write the annotation but not the microdescriptor, rewind.Nick Mathewson
This fixes bug 9047 (and some parts of 9031, 8922, 8883 that weren't fixed in 8822). Bugfix on 0.2.2.6-alpha.
2013-06-12Revert "Use the FILE_SHARE_DELETE flag for CreateFile on a mapping"Nick Mathewson
This reverts commit 884a0e269c382f9e927d8c8b1ef4ef9d2d48379d. I'm reverting this because it doesn't actually make the problem go away. It appears that instead we need to do unmap-then-replace.
2013-06-12Merge remote-tracking branch 'public/bug2077_share_delete' into maint-0.2.4Nick Mathewson
2013-06-12Use the FILE_SHARE_DELETE flag for CreateFile on a mappingNick Mathewson
A comment by rransom on #8795 taken together with a comment by doorss recorded on #2077 suggest that *every* attempt to replace the md cache will fail on Vista/Win7 if we don't have the FILE_SHARE_DELETE flag passed to CreateFile, and if we try to replace the file ourselves before unmapping it. I'm adding the FILE_SHARE_DELETE, since that's this simplest fix. Broken indexers (the favored #2077 hypothesis) could still cause trouble here, but at least this patch should make us stop stepping on our own feet. Likely fix for #2077 and its numerous duplicates. Bugfix on 0.2.2.6-alpha, which first had a microdescriptor cache that would get replaced before remapping it.
2013-03-19Merge remote-tracking branch 'public/bug8002' into maint-0.2.4Nick Mathewson