summaryrefslogtreecommitdiff
path: root/src/common/compat.c
AgeCommit message (Collapse)Author
2017-09-15Run our #else/#endif annotator on our source code.Nick Mathewson
2017-09-15Split some long #if lines to make the #endif annotator happyNick Mathewson
2017-08-07fix typo in commentRoger Dingledine
2017-08-04Tweak usage of get_current_working_dir() for tor_malloc() paranoia.Nick Mathewson
We assume that tor_free() is not required to be compatible with the platform malloc(), so we need to use a strdup here.
2017-08-04Refactor retrieving the current working directorycypherpunks
The GNU C Library (glibc) offers an function which allocates the necessary memory automatically [0]. When it is available, we use that. Otherwise we depend upon the `getcwd` function which requires a preallocated buffer (and its size). This function was used incorrectly by depending on the initial buffer size being big enough and otherwise failing to return the current working directory. The proper way of getting the current working directory requires a loop which doubles the buffer size if `getcwd` requires it. This code was copied from [1] with modifications to fit the context. [0] https://www.gnu.org/software/hurd/hurd/porting/guidelines.html [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html
2017-07-07Use LANG_ENGLISH in windows error messagesNick Mathewson
This change prevents us from generating corrupt messages when we are confused about codepage settings, and makes Windows errors consistent with the rest of our logs. Fixes bug 22520; bugfix on 0.1.2.8-alpha. Patch from "Vort".
2017-07-05Fix mixed-sign comparison warning in fix for 22797.Nick Mathewson
2017-07-05Merge branch 'maint-0.3.0' into maint-0.3.1Nick Mathewson
2017-07-05Merge branch 'maint-0.2.9' into maint-0.3.0Nick Mathewson
2017-07-05Merge branch 'maint-0.2.8' into maint-0.2.9Nick Mathewson
2017-07-05Merge branch 'maint-0.2.7-redux' into maint-0.2.8Nick Mathewson
2017-07-05Merge branch 'maint-0.2.6' into maint-0.2.7-reduxNick Mathewson
2017-07-05Merge branch 'maint-0.2.5' into maint-0.2.6Nick Mathewson
2017-07-05Merge branch 'maint-0.2.4' into maint-0.2.5Nick Mathewson
2017-07-05Merge branch 'teor-bug22797-025' into maint-0.3.1Nick Mathewson
2017-07-05Always allow extra file descriptors when setting the connection maximumteor
When setting the maximum number of connections allowed by the OS, always allow some extra file descriptors for other files. Fixes bug 22797; bugfix on 0.2.0.10-alpha.
2017-07-03Fix assertion failure related to openbsd strtol().Nick Mathewson
Fixes bug 22789; bugfix on 0.2.3.8-alpha.
2017-05-26Cleanup MOCK_IMPL (etc) to be findable with etagsNick Mathewson
A fair number of our mock_impl declarations were messed up so that even our special AM_ETAGSFLAGS couldn't find them. This should be a whitespace-only patch.
2017-03-15Run the copyright update script.Nick Mathewson
2017-03-09Remove fgets() compatbility function and related tests.Alexander Færøy
This patch removes the `tor_fgets()` wrapper around `fgets(3)` since it is no longer needed. The function was created due to inconsistency between the returned values of `fgets(3)` on different versions of Unix when using `fgets(3)` on non-blocking file descriptors, but with the recent changes in bug #21654 we switch from unbuffered to direct I/O on non-blocking file descriptors in our utility module. We continue to use `fgets(3)` directly in the geoip and dirserv module since this usage is considered safe. This patch also removes the test-case that was created to detect differences in the implementation of `fgets(3)` as well as the changes file since these changes was not included in any releases yet. See: https://bugs.torproject.org/21654
2017-03-01Add compatibility function for fgets(3).Alexander Færøy
This patch adds the `tor_fgets()` function to our compatibility layer. `tor_fgets()` adds an additional check for whether the error-bit have been enabled for the given file stream, if that is the case and `errno` is set to `EAGAIN` we make sure that we always return NULL. Unfortunately `fgets(3)` behaves differently on different versions of the C library. See: https://bugs.torproject.org/21416 See: https://bugs.torproject.org/20988
2017-01-25Fix a signed/unsigned comparison warningNick Mathewson
2017-01-25Fail if file is too large to mmap.junglefowl
If tor_mmap_file is called with a file which is larger than SIZE_MAX, only a small part of the file will be memory-mapped due to integer truncation. This can only realistically happen on 32 bit architectures with large file support.
2016-12-16Revert "Stop checking whether environ is declared."Nick Mathewson
This reverts commit 954eeda619a59dae76144ad69967f0ed7341b564. Apparently, OpenBSD is what expects you to declare environ yourself. So 19142 is a wontfix.
2016-12-12Stop checking whether environ is declared.Nick Mathewson
There seems to be pretty good evidence that it's always declared, and that checking for it is pointless. Closes ticket 19142.
2016-11-22Merge remote-tracking branch 'teor/fix-mingw-pagesize'Nick Mathewson
2016-11-08Use va_copy() in pure-windows version of tor_asprintf().Nick Mathewson
It's not okay to use the same varargs list twice, and apparently some windows build environments produce code here that would leave tor_asprintf() broken. Fix for bug 20560; bugfix on 0.2.2.11-alpha when tor_asprintf() was introduced.
2016-11-03Check for getpagesize before using it to mmap filesteor
This fixes compilation in some MinGW environments. Fixes bug 20530; bugfix on commit bf72878 in tor-0.1.2.1-alpha. Reported by "ice".
2016-10-31Actually clamp the number of detected CPUs to 16.Nick Mathewson
Previously we said we did, but didn't. Fixes #19968; bugfix on 0.2.3.1-alpha.
2016-09-09Fix cases where the tests were doing closesocket() on a non-socketNick Mathewson
These seem to have caused warnings on windows. Hmmm.
2016-09-06checkSpace.pl now forbids more identifiers.Nick Mathewson
The functions it warns about are: assert, memcmp, strcat, strcpy, sprintf, malloc, free, realloc, strdup, strndup, calloc. Also, fix a few lingering instances of these in the code. Use other conventions to indicate _intended_ use of assert and malloc/realloc/etc.
2016-08-12Fix integer overflows in the conversion tablescypherpunks
2016-07-29Keep make check-spaces happyAndrea Shepard
2016-07-28Fix a huge pile of -Wshadow warnings.Nick Mathewson
These appeared on some of the Jenkins platforms. Apparently some GCCs care when you shadow globals, and some don't.
2016-07-08Move our "what time is it now" compat functions into a new moduleNick Mathewson
I'm not moving our "format and parse the time" functions, since those have been pretty volatile over the last couple of years.
2016-06-20Small coverage improvements on compat.cNick Mathewson
2016-06-20compat.c coverage: simplify under-tested alloc_getcwd.Nick Mathewson
Yes, HURD lacks PATH_MAX. But we already limited the maximum buffer to 4096, so why not just use that?
2016-06-17Use the Autoconf macro AC_USE_SYSTEM_EXTENSIONScypherpunks
The Autoconf macro AC_USE_SYSTEM_EXTENSIONS defines preprocessor macros which turn on extensions to C and POSIX. The macro also makes it easier for developers to use the extensions without needing (or forgetting) to define them manually. The macro can be safely used because it was introduced in Autoconf 2.60 and Tor requires Autoconf 2.63 and above.
2016-06-16add LCOV_EXCL for unreachable exit() blocks in src/commonNick Mathewson
2016-06-15Mark src/common tor_assert(0)/tor_fragile_assert() unreached for coverageNick Mathewson
I audited this to make sure I was only marking ones that really should be unreachable.
2016-05-30Replace nearly all XXX0vv comments with smarter onesNick Mathewson
So, back long ago, XXX012 meant, "before Tor 0.1.2 is released, we had better revisit this comment and fix it!" But we have a huge pile of such comments accumulated for a large number of released versions! Not cool. So, here's what I tried to do: * 0.2.9 and 0.2.8 are retained, since those are not yet released. * XXX+ or XXX++ or XXX++++ or whatever means, "This one looks quite important!" * The others, after one-by-one examination, are downgraded to plain old XXX. Which doesn't mean they aren't a problem -- just that they cannot possibly be a release-blocking problem.
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-02-28clean/extend some module docs, including fix from #18403Nick Mathewson
2016-02-27Update the copyright year.Nick Mathewson
2016-02-16Merge branch 'bug17852_revised'Nick Mathewson
2016-01-27Correct further grammatical errors in tor commentsNick Mathewson
Avoid using a pronoun where it makes comments unclear. Avoid using gender for things that don't have it. Avoid assigning gender to people unnecessarily.
2016-01-13Add tests for options_actOla Bini