Commit Graph

2092 Commits

Author SHA1 Message Date
Nicolas Williams
c607135a03 Use fallthrough statement attribute (moar) 2022-01-14 16:53:34 -06:00
Nicolas Williams
ddc6113610 Use fallthrough statement attribute 2022-01-14 16:32:58 -06:00
Jeffrey Altman
6426e7550f roken: do not globally define 'timezone' and 'tzname'
ec866e635e
("Windows 10 SDK build fixes") introduced CPP macros

  timezone -> _timezone
  tzname   -> _tzname

but these names are common and the macros rewrite too much.

The name mapping is only required when building strftime.c
with Visual Studio 2017 and later.  Move the definitions
into strftime.c.

Change-Id: Ic813bff842124595fd3d86761cee6dcea4ae44e4
2022-01-14 14:56:39 -05:00
Nicolas Williams
94bb267a8b roken: Delete getcap/cgetent/cgetstr() 2022-01-14 12:01:33 -06:00
Nicolas Williams
a90e1cb65c roken: Fix warnings 2022-01-14 12:01:33 -06:00
Jeffrey Altman
05781f22ab roken: fix net_write if _WIN32 and !SOCKET_IS_NOT_AN_FD
12826c9586
("Handle partial writes on non-blocking sockets") introduced
unconditional use of 'use_write' which is only declared if
defined(SOCKET_IS_NOT_AN_FD).

Change-Id: I0c43ed44a86b4f245acba849afabeb9ce739d0e5
2022-01-14 12:35:50 -05:00
Nicolas Williams
4d8badc9a8 roken: Handle not having getpwnam_r() 2022-01-13 19:56:02 -06:00
Luke Howard
e06eeb5256 roken: use %zu format string for size_t 2022-01-06 22:36:48 +11:00
Luke Howard
0a4830068f roken: use %zu format string for size_t 2022-01-06 17:52:00 +11:00
Luke Howard
ec866e635e Windows 10 SDK build fixes
Build without Win32.mak, and using Universal C Runtime (UCRT)

windows: Check for APPVER, not VCVER for UCRT

When deciding whether UCRT is used (and thus no CRT merge modules), check for
Windows 10 rather than the version of Visual Studio, as we may be building with
an older SDK.
2022-01-05 12:58:48 -06:00
Luke Howard
466658e929 Revert "Windows 10 SDK build fixes"
This reverts commit ceef0a0089.
2022-01-04 14:44:13 +11:00
Luke Howard
ceef0a0089 Windows 10 SDK build fixes
Build without Win32.mak, and using Universal C Runtime (UCRT)

windows: Check for APPVER, not VCVER for UCRT

When deciding whether UCRT is used (and thus no CRT merge modules), check for
Windows 10 rather than the version of Visual Studio, as we may be building with
an older SDK.
2022-01-03 09:25:18 -05:00
Jeffrey Altman
95021a3284 roken: ndbm_wrap support for db6
use the db6/db.h header if present on the system.
2022-01-03 18:09:08 +11:00
Nicolas Williams
a849015350 roken: Fix mergesort_r() clang-13 build 2022-01-02 20:53:09 -06:00
Luke Howard
7cd99b86d3 roken: include MIT license text 2021-12-22 14:45:35 +11:00
Luke Howard
9aa67e58ba roken: don't call assert() before variable decl 2021-12-22 13:43:17 +11:00
Luke Howard
b3bb3ac49d roken: add rk_clzll() helper function 2021-12-22 10:36:26 +11:00
Luke Howard
2bb85f61e9 roken: unbreak Windows build 2021-12-21 08:19:31 +11:00
Nicolas Williams
686d5116de roken: Unparse wider ints 2021-12-18 11:34:12 +11:00
Nicolas Williams
beae9c3c43 roken: Use ptsname_r() if we have it 2021-11-30 11:42:00 -05:00
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Luke Howard
071b95e683 roken: fix theoretical leak introduced in 7fbe7be6
split_spec() should free output parameters if it fails. This was not a leak in
practice because its single caller cleaned up anyway, but cleaning up for good
hygiene.
2021-09-23 10:32:45 +10:00
Luke Howard
7fbe7be675 roken: check strdup succeeds in roken_gethostby_setup()
Closes: #824
2021-09-20 17:58:19 +10:00
Nicolas Williams
2f57f31cd7 roken: Improve test-getuserinfo 2021-09-15 16:05:30 -05:00
Nicolas Williams
0e8323ccee roken: Do not pass NULL to getpwnam_r() 2021-09-15 10:56:19 -05:00
Luke Howard
ab8d4f508e roken: fix dependency typo - s/vin_h/vis_h/
Should close #777, #794.
2021-08-08 19:54:25 +10:00
Andrew Bartlett
75829cad18 Avoid -Werror=strict-overflow on in rk_dns_srv_order()
In a strict Samba build with -Werror=strict-overflow on Ubuntu 18.04
with gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
we see

../../source4/heimdal/lib/roken/resolve.c: In function ‘rk_dns_srv_order’:
../../source4/heimdal/lib/roken/resolve.c:639:7: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
     if(num_srv == 0)
       ^
cc1: all warnings being treated as errors

This avoids the issue by additionally setting a distinct flag.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-08-06 12:24:04 +10:00
Nicolas Williams
f6ac4ee864 roken: Fix parse flags bug 2021-06-22 13:01:24 -05:00
Luke Howard
f67dd0f903 roken: move Heimdal vis.h extensions to separate header
vis.h is not built on platforms (such as macOS) that already have
that header, which resulted in prototypes for Heimdal-specific
vis.h extensions being absent.

Move those prototypes to a separate header, vis-extras.h, which
must be explicitly included in order to use the Heimdal extensions.
2021-05-17 10:05:58 +10:00
Nicolas Williams
034413892e roken: Fix Makefile race 2021-04-26 14:40:00 -05:00
Nicolas Williams
e3359f6bf5 roken: Install useful rk utils 2021-04-23 22:15:51 -05:00
Nicolas Williams
eb2bd63207 roken: Fix OS X build? 2021-03-27 11:35:21 -05:00
Nicolas Williams
d5099a8d3b roken: Take https://github.com/dlfcn-w32/dlfcn-w32
This is a much better and more complete implementation of POSIX RTLD
functions than what we had.  In particular this gets us a more complete
`dladdr()` implementation.
2021-02-22 00:21:45 -06:00
Nicolas Williams
6aefc255b6 roken: Fix rk_strrasvisx() bug 2021-01-26 22:34:36 -06:00
Nicolas Williams
5cefb340ac roken: Make strpool more efficient
Grow the buffer more than absolutely needed, but not too fast.
2021-01-14 18:24:43 -06:00
Nicolas Williams
d336730534 roken: Add (re)allocating strvis functions
These are a Heimdal innovation.
2021-01-13 20:17:58 -06:00
Nicolas Williams
01fb86c0a6 roken: rk_strpoolfree(NULL) should work 2020-12-18 00:44:47 -06:00
Luke Howard
0c0ac807c1 roken: socket test style fixes
Make error reporting in socket test programs consistent with other usages by
removing redundant newline, using strerror() and reporting error in
parentheses.
2020-08-31 16:02:09 +10:00
Jeffrey Altman
51912c0215 roken: introduce rk_socket_set_keepalive
Change-Id: I3086a10cd3d23bef00336f5db7db3a35ca02d568
2020-07-24 01:32:34 -04:00
Andrew Bartlett
bf3c4219fe Make rk_SOCK_INIT an inline function and check the result to avoid warnings
Similar to f6e0d19cc0 but
fixed in the header by making it a proper static inline
function (as some callers treats it as one, so do it
for all now for consistency).

Seen on Ubuntu 18.04 with

giving:

In file included from getaddrinfo-test.c:36:0:
getaddrinfo-test.c: In function ‘main’:
roken.h:110:24: error: statement with no effect [-Werror=unused-value]
 #define rk_SOCK_INIT() 0
                        ^
getaddrinfo-test.c:132:5: note: in expansion of macro ‘rk_SOCK_INIT’
     rk_SOCK_INIT();
     ^~~~~~~~~~~~

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2020-05-28 11:10:57 -04:00
Jeffrey Altman
d4c0d34548 lib/krb5: krb5_get_instance does not work on Windows 7
krb5_get_instance() is meant to ensure that the shared library
instance of heimdal loaded by a plugin matches the instance that
loaded the plugin.  It works by declaring a static C string whose
memory address will be used as an instance identifier.  If the
instance returned from the plugin matches the instance obtain
by the code that loads the plugin, then we can conclude the two
instances are the same.

This doesn't work on Windows 7.  When heimdal.dll loads a plugin
that is linked to heimdal.dll, the plugin's heimdal.dll is always
a new instance.  However, the requirement for plugin safety is
not that the plugin be the same instance in memory but that they
be the same instance on disk.

This change loads the path name and version string for the module
and generates a hash of those strings as an instance identifier.

Change-Id: I1c0651969e9738c5feecb0b323969d13efd4704d
2020-05-27 23:22:40 -05:00
Jeffrey Altman
f77618ef15 roken: stdint.hin libtommath 1.2.0 needs more
libtommath 1.2.0 c403b66082
("hcrypto: import libtommath v1.2.0") needs more from stdint.h
than what Heimdal previously declared.  Add more integer type
declarations and integer MIN/MAX macros.

Also, on Windows declare 64-bit integers using __int64 as
"long long" is not supported as 64-bit type across all visual
studio compiler versions.

Change-Id: I944bedc67bcb26374ffb30eb3dfd7c6108a98fc3
2020-05-26 11:48:45 -05:00
Nicolas Williams
9794f02245 roken: fix valgrind leak noise 2020-04-24 16:02:35 -05:00
Luke Howard
1c74afb01a roken: add mergesort_r()
Add mergesort_r() as a stable sort function that can be used by other
components of Heimdal. Note that there is no standardized prototype for this
function, however it appears that both FreeBSD and glibc would adopt the glibc
convention (where the private data argument appears last). See:

    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214248
2020-04-12 13:25:09 -05:00
Nicolas Williams
64d5f86ec3 Fix warnings (some bugs, some spurious)
Many spurious VC warnings not quieted though.
2020-03-12 21:02:09 -05:00
Nicolas Williams
a7359d6898 roken: Add mkdtemp() 2020-03-02 17:48:04 -06:00
Nicolas Williams
77619f245d roken: Add base32 2020-03-02 17:48:04 -06:00
Luke Howard
3daef8a5fd roken: Windows version support helpers
Add helper functions for determining the version of Windows upon which we are
running.
2019-12-05 20:20:28 -05:00
Nicolas Williams
f9a0e8f076 roken: add rkbase64 noinst program
This will be useful in tests.
2019-12-04 13:40:28 -06:00
Nicolas Williams
982ba80b6e roken: fix leak in roken_detach_prep() 2019-12-04 13:40:28 -06:00