80 Commits

Author SHA1 Message Date
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
Viktor Dukhovni
32f8564296 Fix incorrect scaling of weight 0 SRV records
Loosely based on patch by Nico.
2016-12-12 17:51:13 -05:00
Viktor Dukhovni
da8052fefc Don't scale SRV weights when none have weight zero 2016-11-13 15:22:17 +11:00
Roland C. Dowdeswell
eb682c1bf4 Fix weight zero entries when ordering SRV RR results.
In lib/roken/resolve.c, we find rk_dns_srv_order() which re-orders
the results of an SRV RR lookup by the algorithm in RFC2782.  We
note that the algorithm doesn't behave according to the RFC w.r.t.
entries of weight zero.  We solve this by scaling out the remaining
weights by the number of zeros we find at a particular priority
level and acting like the zero weights have a weight of one.
2016-11-10 04:45:07 -05:00
Roland C. Dowdeswell
44a1a2a273 Fix bias in ordering SRV RR results by weight.
In lib/roken/resolve.c, we find rk_dns_srv_order() which re-orders
the results of an SRV RR lookup by the algorithm in RFC2782.  We
fix a bias in the random weight sorting by changing the order of
operations when selecting rnd.  rnd should be a non-zero random
number less than the sum of the weights at a particular priority,
but zero was included as a legitimate output thus biasing the
selection process.  rk_random() % sum is still biased as a 32
bit int modulo a number which doesn't divide 2^32 does not have
a uniform distribution, but the bias should be small enough to
live with for our purposes here.
2016-11-10 04:45:07 -05:00
Love Hornquist Astrand
8e455dc774 dont use initstate/setstate 2011-09-21 17:38:21 +02:00
Love Hornquist Astrand
d931fd0a22 Free handle when done so that we don't leak memory
Memory leak reported by Craig Ruff
2011-08-31 11:46:37 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
987faedb80 add random abstraction 2010-11-29 09:31:07 -08:00
Love Hornquist Astrand
dc1baf6ab4 only support DS record conversion if DNS_TYPE_DS is defined 2010-06-01 10:54:47 -07:00
Asanka Herath
884f5ac627 Use WinDNS on Windows for DNS 2010-05-26 10:38:41 -04:00
Love Hornquist Astrand
b0a79dcd40 Improve the dns retry logic
Bug reported by Richard Silverman on heimdal-bugs
2010-03-19 14:19:43 -07: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
Love Hornquist Astrand
c5264d42f4 drop rcsid 2009-09-07 21:24:36 -07:00
Love Hörnquist Åstrand
b347f67b02 use res_ for platforms w/o dns_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24963 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-27 14:55:46 +00:00
Love Hörnquist Åstrand
9697d2a91c stop using Bind4 types
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24895 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-22 17:19:15 +00:00
Love Hörnquist Åstrand
a61934489a Use dns_ API when available. Om MacOS this avoids repeted lookups
since it uses the mDNSResponder to cache the replies.

Remove support debugging using the old res_ API.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24881 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-22 17:16:40 +00:00
Love Hörnquist Åstrand
355a7f54e5 prefix names
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24879 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-22 17:16:19 +00: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
6b618c3b0b Use unsigned where appropriate.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22873 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-04-07 18:50:39 +00:00
Love Hörnquist Åstrand
0cf980c265 Try harder to call res_ndestroy().
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19869 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 16:03:14 +00:00
Love Hörnquist Åstrand
bd62812bd8 update (c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19868 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 15:43:30 +00:00
Love Hörnquist Åstrand
0b29b91f6f (dns_srv_order): change a if (ptr == NULL) continue into a assert(ptr
!= NULL) since it could never happen, found by the IBM code checker (beam).
Thanks to Florian Krohm for explaining it.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17063 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-14 13:56:00 +00:00
Love Hörnquist Åstrand
16a5f30931 Plug memory leak found by IBM checker (and try to please it).
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16923 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-02 00:01:55 +00:00
Love Hörnquist Åstrand
59fade5fcd Spelling, from Alexey Dobriyan, via Jason McIntyre
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16724 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-02-06 19:30:16 +00:00
Love Hörnquist Åstrand
8c05794963 (dns_lookup_int): if we have res_ndestroy, prefeer that before res_nclose
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15945 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-08-22 19:16:21 +00:00
Love Hörnquist Åstrand
761bb32c40 (parse_record): fix casting to avoid losing const
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15411 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-16 16:46:16 +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
Love Hörnquist Åstrand
f4727981b9 (dns_lookup_int): s/stat/state/ to avoid shadowing
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14697 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-03-30 16:47:18 +00:00
Love Hörnquist Åstrand
236be3a565 put dns_type_to_string and dns_string_to_type in the abi
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14319 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-10-16 12:19:13 +00:00
Love Hörnquist Åstrand
0641d8970d add ds_record
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14318 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-10-16 12:17:47 +00:00
Love Hörnquist Åstrand
15b169c7a5 (dns_lookup_int): grow the answer buffer to the size the server send
to us if the answer buffer was too small (limited to the dns protocol
max packet size)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14212 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-09-11 20:38:55 +00:00
Love Hörnquist Åstrand
e8acf0bd31 add and use and bind9 version of rr type (rk_ns_t_XXX) instead of the
old bind4 version (T_XXX)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13945 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-06-20 17:50:09 +00:00
Love Hörnquist Åstrand
8f34150dd9 (stot): add AAAA
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13862 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-05-25 20:14:54 +00:00
Love Hörnquist Åstrand
aacc963b39 parse dns header, add support for SSHFP
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13220 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-12-14 15:43:10 +00:00
Love Hörnquist Åstrand
3a16c33025 number-of fields no longer stored in network order
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13214 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-12-14 09:26:58 +00:00
Love Hörnquist Åstrand
f23430751a remove depency on c99 types in resolv.h
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13212 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-12-13 20:34:51 +00:00
Love Hörnquist Åstrand
beca19cb05 AIX have broken res_nsearch() in 5.1 (5.0 also ?)
so just don't use res_nsearch on AIX


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12431 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-07-11 15:41:40 +00:00
Love Hörnquist Åstrand
aa5a63a286 copy NUL too, from janj@wenf.org via openbsd
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12102 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-04-22 14:59:12 +00:00
Love Hörnquist Åstrand
815445af73 use strlcpy, from openbsd
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12050 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-04-16 16:28:03 +00:00
Johan Danielsson
82a11004de check length of txt records
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11475 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-10-15 15:20:40 +00:00
Johan Danielsson
14a69cb275 fix res_nsearch call, but don't use it for now, AIX5 has a broken
version that trashes memory


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11419 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-09 21:39:19 +00:00
Johan Danielsson
f956bbce07 use res_nsearch if we have it (from Larry Greenfield)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11382 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-04 20:55:20 +00:00
Assar Westerlund
03d1e81671 (parse_reply): update the arguments to more reasonable types. allow
parse_reply-test to call it


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11353 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-03 21:34:44 +00:00
Johan Danielsson
65864e2302 (dns_srv_order): do alignment tricks with the random() state (from NetBSD)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11283 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-08-28 20:07:24 +00:00
Assar Westerlund
d6a7b8a83e (parse_reply): verify the lengths (both external and internal) are
consistent and not too long
(dns_lookup_int): be conservative in the length sent in to to
parse_reply


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11239 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-08-27 20:07:02 +00:00
Johan Danielsson
5d1e7df512 _res might not be available
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11171 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-08-20 15:52:57 +00:00