summaryrefslogtreecommitdiffstats
path: root/src/include/k5-platform.h
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate internal fixed-width type wrappersGreg Hudson2014-02-261-17/+14
| | | | | Directly use stdint.h names for integer types in preference to the various internal names we have made up for them.
* Assume <stdint.h> and fixed-width typesGreg Hudson2014-02-261-36/+3
| | | | | | | Make unconditional use of <stdint.h> and fixed-width types such as uint32_t. k5-plugin.h doesn't use any special integer types, so remove the conditional include block there. Nothing uses INT64_FMT/UINT64_FMT, so leave those out of k5-platform.h for now.
* Make set_cloexec_fd return voidBen Kaduk2013-11-041-10/+7
| | | | | | | | | We never check its return value (causing clang to emit warnings), and its use is primarily in cases where we should continue processing in the event of failure. Just ignore errors from the underlying fcntl() call (if present) and treat this operation as best-effort. The #if 0 code should probably be removed.
* Add an internal constant-time comparison functionGreg Hudson2013-10-031-0/+8
| | | | | | | k5_bcmp acts similarly to the deprecated Unix bcmp() function, returning zero if two memory regions are equal and nonzero if they are not. It is implemented such that it should take the same amount of time regardless of how many bytes are equal within the memory regions.
* Fix windows buildBen Kaduk2013-02-251-1/+1
| | | | | | | | | | Catch up to the split of preauth_plugin.h into client and kdc specific portions. While here, use copy's /y flag to suppress an override-confirmation prompt (though we do not list any dependencies for this target at the moment, so no such prompt will be generated). Do not disable library finalizers for windows, erroneously disabled in 4538146e1452e0966164119cefb0804993ce6bbb.
* Don't finalize libraries in static buildGreg Hudson2012-12-121-11/+13
| | | | | | | | | | | | In a build with static libraries, functions tagged with __attribute__((destructor)) may be executed in any order, not in a topologically sorted order as they are in shared libraries. This could result in libcom_err functions being invoked (from another library's finalizer) after libcom_err has been finalized, which would (at minimum) result in using a mutex after it is destroyed. To prevent this kind of problem, disable finalizers in the static build regardless of whether we have compiler or linker support for them. Reported by Mihai Serban <mihai.serban@gmail.com>.
* Add internal JSON encoding and decoding supportGreg Hudson2012-09-111-0/+6
| | | | Add JSON support based loosely on Heimdal's heimbase code.
* Allow using locales when gettext is absentBen Kaduk2012-07-061-5/+3
| | | | | | | | | | | Previously, if configure did not detect dgettext(), we disabled anything that smelled like localization, inadvertently including setlocale(). Now that we use setlocale(LC_ALL, ""), we have localized dates available as well as messages, so we should not disable calls to setlocale() any more. Since the routines from locale.h are only used in a relatively small number of places, just include the header directly in those files and remove it from k5-platform.h.
* Add no-op macro for ngettext for non-NLS buildsGreg Hudson2012-05-091-0/+1
| | | | | | | r25857 (#7128) uses ngettext, which means we need a no-op macro for it when we're building without NLS support. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25859 dc483132-0cff-0310-8789-dd5450dbe970
* Ensure termination in Windows vsnprintf wrapperGreg Hudson2011-10-181-1/+3
| | | | | | | | | | | | | | | The Windows _vsnprintf does not terminate its output buffer in the overflow case. Make sure we do that in the wrapper. Reported by Chris Hecker. (Not an issue for KfW 3.2 since we weren't using snprintf in 1.6.x except in Unix-specific code.) ticket: 6980 target_version: 1.10 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25367 dc483132-0cff-0310-8789-dd5450dbe970
* Add krb5int_gettimeofday to k5sprt for platforms w/o native gettimeofdaySam Hartman2011-10-051-0/+5
| | | | | | | | | | Microsecond accuracy on _WIN32, but only one second accuracy on other, AFAIK purely hypothetical, platforms that lack native gettimeofday. Shamelessly cribbed from Heimdal. Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com> git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25310 dc483132-0cff-0310-8789-dd5450dbe970
* Add fnmatch support to libkrb5supportGreg Hudson2011-09-051-0/+19
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25153 dc483132-0cff-0310-8789-dd5450dbe970
* In last-resort fallback va_copy change 'memcmp' to 'memcpy'Sam Hartman2011-08-091-1/+1
| | | | | | | Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com> Signed-off-by: Sam Hartman <hartmans@painless-security.com> git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25080 dc483132-0cff-0310-8789-dd5450dbe970
* Add internal APIs for portable path manipulationGreg Hudson2011-08-071-0/+22
| | | | | | | | | | | | | k5_path_split separates a path into dirname and basename. k5_path_join joins two paths. k5_path_isabs determines if a path is absolute. All three functions follow the Python path function semantics. Currently the test module doesn't run in the Windows build, but the Windows path semantics are tested in the Unix build using specially built objects. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25074 dc483132-0cff-0310-8789-dd5450dbe970
* Add localization infrastructureGreg Hudson2011-06-101-3/+18
| | | | | | | | | Adds build system logic, translation macros in k5-platform.h, and bindtextdomain calls in libkrb5 initialization. ticket: 6918 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24959 dc483132-0cff-0310-8789-dd5450dbe970
* Adjust most C source files to match the new standards for copyrightGreg Hudson2011-03-091-4/+4
| | | | | | and license comments. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24695 dc483132-0cff-0310-8789-dd5450dbe970
* Use bswap16 and bswap32 on NetBSDKen Raeburn2010-02-201-2/+14
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23741 dc483132-0cff-0310-8789-dd5450dbe970
* Temporarily define UINT16_TYPE and UINT32_TYPE so the load/storeKen Raeburn2009-12-031-24/+15
| | | | | | functions don't need excessive conditionals internally. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23437 dc483132-0cff-0310-8789-dd5450dbe970
* Add store_{16,32,64}_n functions, for potentially-unaligned, native-order valuesKen Raeburn2009-12-021-0/+29
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23431 dc483132-0cff-0310-8789-dd5450dbe970
* Punt the volatile cast in the non-gcc, non-Windows version of zap.Greg Hudson2009-11-241-0/+2
| | | | | | | Use a function call into libkrb5support instead, since that's hard to inline. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23339 dc483132-0cff-0310-8789-dd5450dbe970
* Reindent include directory, reformatting prototypes as necessary.Greg Hudson2009-11-141-142/+143
| | | | | | | Exclude include/gssrpc due to its Sun origin and k5-platform.h due to macros too hairy for emacs c-mode to handle. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23180 dc483132-0cff-0310-8789-dd5450dbe970
* make mark-cstyleTom Yu2009-10-311-2/+2
| | | | | | make reindent git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23100 dc483132-0cff-0310-8789-dd5450dbe970
* Fix stupid logic bug in last versionKen Raeburn2009-09-151-2/+2
| | | | | | ticket: 6565 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22766 dc483132-0cff-0310-8789-dd5450dbe970
* Check __BIG_ENDIAN__ and __LITTLE_ENDIAN__ to determine endianness.Ken Raeburn2009-09-151-2/+6
| | | | | | | | | In fallback code, check ia64 platforms for hpux vs everything else; HP-UX uses big-endian mode. ticket: 6565 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22761 dc483132-0cff-0310-8789-dd5450dbe970
* Include <assert.h> in k5-platform.h, since we use assertions in someGreg Hudson2009-07-301-0/+1
| | | | | | | | | | | of the macros defined there, as well as in many source files which do not themselves include <assert.h>. Report and fix by Rainer Weikusat. ticket: 6533 tags: pullup target_version: 1.7 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22475 dc483132-0cff-0310-8789-dd5450dbe970
* k5-platform.h no longer takes responsibility for making "staticGreg Hudson2009-07-011-1/+0
| | | | | | inline" work, so remove the comment which says it does. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22425 dc483132-0cff-0310-8789-dd5450dbe970
* define SSIZE_MAX forWindowsKen Raeburn2009-02-111-0/+4
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21956 dc483132-0cff-0310-8789-dd5450dbe970
* C++ compatibility fix -- g++ says "types may not be defined in casts",Ken Raeburn2009-02-091-24/+24
| | | | | | so do the gcc unaligned-struct trick only for C, not C++. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21917 dc483132-0cff-0310-8789-dd5450dbe970
* use casts, for c++ compilation on windowsKen Raeburn2009-02-051-12/+14
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21902 dc483132-0cff-0310-8789-dd5450dbe970
* declare replacement [v]asprintf functionsKen Raeburn2009-02-051-5/+9
| | | | | | | | | | | | | | | If HAVE_VASPRINTF is not defined, make sure krb5int_{,v}asprintf functions always get declared, applying the preprocessor conditional test only to the GCC format attribute. If HAVE_VASPRINTF is defined, don't declare them at all. This fixes a bunch of function-not-declared warnings under Sun cc. ticket: 6364 target_version: 1.7 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21888 dc483132-0cff-0310-8789-dd5450dbe970
* Change 16/32/64-bit big-/little-endian/native unaligned load/storeKen Raeburn2009-01-241-16/+28
| | | | | | | | routines to take void pointers, so they can operate on both plain and unsigned char buffers, or other types. Remove some now-unneeded casts. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21793 dc483132-0cff-0310-8789-dd5450dbe970
* Add build system support for strlcpy and strlcat on platforms which doGreg Hudson2008-10-241-0/+8
| | | | | | | | | not provide it natively. ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20916 dc483132-0cff-0310-8789-dd5450dbe970
* Use snprintf instead of strcpy/strcat in many placesGreg Hudson2008-10-231-0/+16
| | | | | | | ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20912 dc483132-0cff-0310-8789-dd5450dbe970
* Now that we have support for conditionally exporting symbols from the supportKen Raeburn2008-10-151-74/+5
| | | | | | library, use that for the [v]asprintf replacement functions when needed. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20871 dc483132-0cff-0310-8789-dd5450dbe970
* Fix vasprintf signed/unsigned mix; separate out duplicated error paths; pull ↵Ken Raeburn2008-08-291-26/+40
| | | | | | success return path out of guts of loop git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20703 dc483132-0cff-0310-8789-dd5450dbe970
* Merge from branch sun-ipropKen Raeburn2008-06-241-2/+5
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20465 dc483132-0cff-0310-8789-dd5450dbe970
* Implement SWAP16 for Mac without compiler warningKen Raeburn2007-12-221-1/+9
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20194 dc483132-0cff-0310-8789-dd5450dbe970
* On Windows, UINT64_MAX isn't defined; define itKevin Koch2007-11-151-0/+4
| | | | | | | | TargetVersion: 1.7 Component: krb5-libs Ticket: 5594 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20166 dc483132-0cff-0310-8789-dd5450dbe970
* On Mac, include TargetConditionals.h and architecture/byte_order.h,Ken Raeburn2007-10-291-0/+28
| | | | | | | | | and use OSSwapInt{16,32,64} for SWAP* macros. Add k5_htonll and k5_ntohll functions. (Implementation assumes the swapping is its own reverse on all platforms we support.) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20150 dc483132-0cff-0310-8789-dd5450dbe970
* Set close-on-exec flag in most places where file descriptors areKen Raeburn2007-10-221-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | opened in our libraries (in case another application thread spawns a new process) and in the KDC programs (in case a plugin library spawns a new process). Checked calls to: open fopen THREEPARAMOPEN mkstemp socket accept dup dup2 pipe. In: util lib plugins kdc kadmin/server krb524. The various programs are less critical than the libraries, as any well-written plugin that spawns a new process should close all file descriptors it doesn't need to communicate with the new process. This approach also isn't bulletproof, as the call to set the close-on-exec flag is necessarily a separate call from creating the file descriptor, and the fork call could happen in between them. So plugins should be careful regardless of this patch; it will only reduce the window of potential lossage should a plugin be poorly written. (AFAIK there are currently no plugins that spawn processes where this would be a problem.) Update dependencies. ticket: 5561 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20143 dc483132-0cff-0310-8789-dd5450dbe970
* Define snprintf along with vsnprintf for WindowsKen Raeburn2007-08-011-0/+11
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19742 dc483132-0cff-0310-8789-dd5450dbe970
* Provide {,v}asprintf prototypes if neededKen Raeburn2007-07-271-0/+15
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19735 dc483132-0cff-0310-8789-dd5450dbe970
* Under gcc, declare k5_v?asprintf with format attributeKen Raeburn2007-06-291-0/+8
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19654 dc483132-0cff-0310-8789-dd5450dbe970
* For Win32 environment, define CAN_COPY_VA_LIST, and define an inlineKen Raeburn2007-06-271-1/+21
| | | | | | | version of vsnprintf using the MS versions. (Apparently no need for plain snprintf just yet.) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19644 dc483132-0cff-0310-8789-dd5450dbe970
* If mkstemp is missing, define the mkstemp macro is k5-platform.h, not autoconf.hKen Raeburn2007-06-271-0/+1
| | | | git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19643 dc483132-0cff-0310-8789-dd5450dbe970
* Add the libdb2 type-existence tests to the top-level configure script.Ken Raeburn2007-06-201-0/+1
| | | | | | | | | | | Replace the generated header files in db2 with static ones that include autoconf.h and make decisions based on the macros defined there. Omit some tests that test for things we assume now, like "const" working and "size_t" being defined. Update dependencies. The libdb2 configure script now generates no header files. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19605 dc483132-0cff-0310-8789-dd5450dbe970
* Move (BSD-licensed) mkstemp from libdb2 to libkrb5support, and renameKen Raeburn2007-06-201-0/+3
| | | | | | | | | | | | | the function to krb5int_mkstemp. Generate the symbol export list for libkrb5support at build time. Declare krb5int_mkstemp in k5-platform.h. Change cc_file.c to use mkstemp unconditionally. Make libdb2.so (built for testing only) link against the libkrb5support, and use krb5int_mkstemp if mkstemp is not available. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19600 dc483132-0cff-0310-8789-dd5450dbe970
* provide asprintf functionality for internal useKen Raeburn2007-06-201-3/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I plan to use asprintf in some gssapi error-message management routines, so let's make sure we have the functionality available, implementing it locally if necessary. This implementation assumes vsnprintf is available, an assumption that the support library is already making at the moment. Since this implementation requires calling vsnprintf potentially multiple times with the same va_list, use va_copy if it's available, or provide a hack version (which should work okay if va_list is a scalar or array type that requires no other special handling, and if va_end does nothing interesting, which is usually the case) if the compiler doesn't provide it. I also changed a couple bits of code to use asprintf, to make sure we exercise our implementation in testing. (C99 requires vsnprintf and va_copy; vasprintf is a GNU/BSD extension, but an oh so useful one....) * configure.in: Check for va_copy, or if va_list objects can be simply assigned. Define HAS_VA_COPY and CAN_COPY_VA_LIST as appropriate. * include/k5-platform.h: Define a va_copy macro if the compiler doesn't provide it. * include/k5-platform.h: If vsnprintf isn't available from the OS, abort compilation. If vasprintf isn't available from the OS, provide k5_{v,}asprintf based on vsnprintf and define {v,}asprintf macros. * lib/krb5/keytab/t_keytab.c (do_test): Use asprintf. * util/support/errors.c (krb5int_vset_error): Use asprintf unconditionally. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19595 dc483132-0cff-0310-8789-dd5450dbe970
* Use "unsigned __int{16,32}" types for Windows in load_{16,32}_n, per KevinKen Raeburn2007-03-141-0/+8
| | | | | | ticket: 5425 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19227 dc483132-0cff-0310-8789-dd5450dbe970
* * include/k5-platform.h: Add load_{16,32,64}_n for loading values fromKen Raeburn2007-03-141-0/+24
| | | | | | | | | | | (possibly unaligned) memory in native order. * lib/krb5/krb/get_in_tkt.c (krb5_get_init_creds): Fetch four random bytes from the crypto library and generate a 31-bit (non-negative) nonce, instead of using the timestamp. ticket: 5425 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19223 dc483132-0cff-0310-8789-dd5450dbe970