Commit Graph

27 Commits

Author SHA1 Message Date
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
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Ted Percival
c93cea7ea6 Fix roken getifaddrs for IPv4 & IPv6 on HP-UX & Solaris
HP-UX only returns IPv6 addresses using SIOCGLIFCONF,
SIOCGIFCONF has to be used for IPv4 addresses.
Solaris uses the same code as described in the comments, which
should correctly detect all addresses when running in a zone.

This adds the code that went missing from commit e20183da.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-12-07 18:40:46 -08:00
Ted Percival
e20183da23 Fix roken getifaddrs for IPv4 & IPv6 on HP-UX & Solaris
HP-UX only returns IPv6 addresses using SIOCGLIFCONF,
SIOCGIFCONF has to be used for IPv4 addresses.
Solaris uses the same code as described in the comments, which
should correctly detect all addresses when running in a zone.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-12-04 20:46:15 -08:00
Ted Percival
54817ef6f3 Revert "Try both v4 and v6 socket types"
It broke detection of IPv4 addresses on HP-UX machines with an IPv6
loopback address. Successful resolution of at least one IPv6 address
would then skip doing a separate IPv4 lookup as required by HP-UX.

This reverts commit 76afc31e9b.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-12-04 20:39:42 -08:00
Ted Percival
7fc0f55b89 Fix duplicate definition of rk_freeifaddrs
Introduced by incorrectly moving an ifdef in commit d00f998.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-12-04 20:07:42 -08:00
Asanka Herath
d00f9984a5 Make roken build on windows
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-24 21:42:02 -08:00
Anton Lundin
76afc31e9b Try both v4 and v6 socket types
The libroken-getifaddrs fails to retrive the ipv6-address in
solaris-zones but it might connect over ipv6 anyway, and then the kdc
refuses to give a ticket with the cryptic message:

kinit: krb5_get_init_creds: No ENC-TS found

A saner message ends up in the kdc's logfile.

because of a ENXIO when looking for a ipv6-address on the
ipv4-interface, the whole getlifaddrs2 fails and getifaddrs2 is run
instead and it just discovers the ipv4-address.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-08-20 07:51:56 -07:00
Ted Percival
1cbb0e766d Fix crash in rk_freeifaddrs due to freeing an invalid pointer
Crash occurs on Linux systems that support AF_NETLINK but do not have
getifaddrs() in libc (eg. SuSE 8.1).

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-08-05 12:29:26 +02:00
Love Hörnquist Åstrand
0d31d3d686 drop rcsid
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24356 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:30:37 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
8d40c2994b check return value of alloc functions, from Charles Longeau
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21745 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-31 16:11:25 +00:00
Love Hörnquist Åstrand
a6f5b0d0ac Prefix getifaddrs functions with rk_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19310 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-11 18:59:31 +00:00
Love Hörnquist Åstrand
4c8088c946 Try handle HP/UX 11.nn
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16387 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-12-12 15:14:51 +00:00
Love Hörnquist Åstrand
c079388c13 (nl_getlist): poll to get messages from kernel, and retry if the
message was lost
(free_nlmsglist): free all linked elements, not just the first one


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15640 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-07-13 07:58:36 +00:00
Love Hörnquist Åstrand
b69b02125d add break on default: statements, from Douglas E. Engert
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15038 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-04-30 15:45:47 +00:00
Love Hörnquist Åstrand
709aa58c74 define ROKEN_LIB_FUNCTION on all exported functions
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14773 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-04-12 11:29:18 +00:00
Assar Westerlund
f4b53cdfee remove some warnings from the linux-portion
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11397 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-05 03:36:23 +00:00
Assar Westerlund
6aa0fddea7 add Linux AF_NETLINK getifaddrs from Hideaki YOSHIFUJI of the Usagi
project


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11364 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-04 04:26:27 +00:00
Assar Westerlund
442d34ff29 support SIOCGLIFCONF and SIOCGLIFFLAGS which are used on Solaris 8 to
retrieve addresses larger than `struct sockaddr'.  From Magnus Ahltorp
<ahltorp@nada.kth.se> (with some modifications by me)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10794 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-11-30 03:27:30 +00:00
Assar Westerlund
394e4a6ad6 (getifaddrs2): remove unused variables
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10406 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-07-31 01:15:41 +00:00
Johan Danielsson
820d393190 (getifaddrs2): close socket when done
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9782 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-04-17 08:27:47 +00:00
Assar Westerlund
40119c91a7 (getifaddrs2): copy the entire sockaddr
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9554 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-01-28 23:02:46 +00:00
Johan Danielsson
3fccd646d3 free some memory
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9265 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-12-05 09:05:30 +00:00
Johan Danielsson
419ef60ec7 deal with sa_len in test
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9262 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-12-05 05:36:14 +00:00
Johan Danielsson
8ba1739272 getifaddrs implementation using SIOCGIFCONFIG etc
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9255 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-12-04 22:19:40 +00:00