Граф коммитов

113 Коммитов

Автор SHA1 Сообщение Дата
nobu e667897b46 resolv.rb: remove rangerand
* lib/resolv.rb (Resolv::DNS.rangerand): rand and random_number
  accept a Range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06 03:31:46 +00:00
nobu e6c0a8f19e resolv.rb: close socket
* lib/resolv.rb (UnconnectedUDP#lazy_initialize): store new
  sockets before binding, so the sockets get closed when the
  requester is closing.

* lib/resolv.rb (ConnectedUDP#lazy_initialize): ditto.

* lib/resolv.rb (UnconnectedUDP#close): synchronize to get rid of
  race condition.

* lib/resolv.rb (ConnectedUDP#close): ditto.

[ruby-core:85901] [Bug #14571]

From: quixoten (Devin Christensen) <quixoten@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-06 02:48:17 +00:00
nobu 456dc174b6 resolv.rb: NUL hosts
* lib/resolv.rb (Resolv::Hosts::DefaultFileName): fallback to NUL
  device when Win32::Resolv.get_hosts_path() returned nil, to get
  rid of TypeError in lazy_initialize.
  [ruby-core:84907] [Bug #14369]  [Fix GH-1791]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 03:09:39 +00:00
nobu fa5870b9c4 resolv: use safe navigation operator
* lib/resolv.rb (each_address): use safe navigation operator to
  avoid extra hash lookups, as well as each_name since r56890.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 02:44:50 +00:00
naruse 9e677261a9 Mock fetching data from real DNS [Feature #14340]
This test just tests MDNS#each_address method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 18:26:49 +00:00
nobu cdf1b85ae7 Fixed command Injection
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): fixed
  potential command injection by use of Kernel#open.
  [ruby-core:84347] [Bug #14205]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 04:25:01 +00:00
nobu e7464561b5 Fixed command Injection
* resolv.rb (Resolv::Hosts#lazy_initialize): fixed potential
  command Injection in Hosts::new() by use of Kernel#open.
  [Fix GH-1777] [ruby-core:84347] [Bug #14205]

From: Drigg3r <drigg3r@yandex.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 04:18:31 +00:00
hsbt db590b5d59 Fixed unexpected behavior of `Resolv::MDNS#each_address` when given ".local" address.
https://github.com/ruby/ruby/pull/1425

  Patch by @elct9620 [fix GH-1484]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 13:58:31 +00:00
glass f70827b7cf resolv.rb: remove unnecessary require statement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-29 04:58:29 +00:00
nobu 8b8505d239 resolv.rb: byte buffer
* lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): treat the
  data as a byte buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-14 02:26:49 +00:00
nobu 2b2450ba4b Made #decode_rdata client to catch errors
* lib/resolv.rb (Resolv::DNS::Message::MessageDecoder#get_rr):
  re-raise an exception from decode_rdata as DecodeError, so it
  can report them to the top in more informative way.  It was not
  reflecting on errors of data and thus breaking.  Client code
  expects `DecodeError` and knows how to handle broken messages.
  [Fix GH-1511]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-14 02:26:48 +00:00
normal 214eecd391 resolv: use safe navigation operator to avoid extra hash lookups
@addr2name is a private Hash and never changes its default_proc,
so only pay the hash lookup cost once; we know missing entries
in the hash will be nil.

* lib/resolv.rb (each_name): use safe navigation operator

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-23 23:57:30 +00:00
kazu a53fe773d6 Use `&.` instead of modifier if
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-22 13:11:43 +00:00
normal 6d7dc8f7d5 resolv: use symbol proc when possible
This reduces both human code and bytecode.

lib/resolv.rb (sender_for, Config.parse_resolv_conf): use symbol proc

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-21 23:50:31 +00:00
akr 7d27c0a2d8 fix Resolv::LOC::Coord.create.
* lib/resolv.rb (Resolv::LOC::Coord.create): fixed.
  [ruby-core:72567] [Bug #11912] fixed by Eric Wong and Kazuhiro
  NISHIYAMA.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 15:19:21 +00:00
akr 365c321585 extract_resources uses each_resource instead of each_answer.
* lib/resolv.rb (Resolv::DNS#extract_resources): Use each_resource
  instead of each_answer.
  [ruby-core:75461] [Bug#12372] reported by Rafael Fernandez Lopez.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 08:33:03 +00:00
nobu 4b298ad77a Use qualified names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-30 06:22:30 +00:00
normal a3b53cd991 Resolv::IPv6.create: avoid modifying frozen string literal
* lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen
* test/resolv/test_dns.rb (test_ipv6_create): test for above
  [Bug #11910] [ruby-core:72559]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-28 20:31:10 +00:00
akr 68ebbbfebe * lib/open-uri.rb: Remove indicator for "frozen_string_literal: true".
* lib/pp.rb: Ditto.

* lib/prettyprint.rb: Ditto.

* lib/resolv.rb: Ditto.

* lib/securerandom.rb: Ditto.

* lib/tmpdir.rb: Ditto.

* lib/unicode_normalize/tables.rb: Ditto.

* test/net/ftp/test_buffered_socket.rb: Ditto.

* test/net/ftp/test_mlsx_entry.rb: Ditto.

* test/open-uri/test_open-uri.rb: Ditto.

* test/open-uri/test_ssl.rb: Ditto.

* test/pathname/test_pathname.rb: Ditto.

* test/test_pp.rb: Ditto.

* test/test_prettyprint.rb: Ditto.

* tool/transcode-tblgen.rb: Ditto.

* ext/pathname/lib/pathname.rb: Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 11:48:14 +00:00
akr 60055f8dfd * lib/resolv.rb (Resolv::DNS::Message::MessageEncoder#put_labels):
Prevent overflow of pointer to labels.
  Patch by Hannes Georg.  [ruby-core:71248] [Bug #11632]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09 15:37:04 +00:00
akr 36ca18b847 Put an line before "frozen_string_literal: true" for emacs.
https://bugs.ruby-lang.org/issues/8976#note-49


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 22:22:56 +00:00
akr 805c20a8e5 * lib/pp.rb: Use frozen_string_literal: true.
* lib/prettyprint.rb: Ditto.

* lib/resolv.rb: Ditto.

* lib/tmpdir.rb: Ditto.

* test/test_pp.rb: Ditto.

* test/test_prettyprint.rb: Ditto.

* tool/transcode-tblgen.rb: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 13:27:48 +00:00
normal 16aeffefa2 lib/*: use monotonic clock for timeouts
The monotonic clock is preferred as it is guaranteed to be
continuous and not subject to jumps due to adjustments.

* lib/net/resolv.rb (request): use monotonic clock
* lib/net/http.rb (begin_transport, end_transport): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-29 01:40:26 +00:00
normal 84b012e02a stdlib: use IO#wait_*able instead of IO.select when possible
In case a process encounters high-numbered FDs, this allows
consistent performance on systems with ppoll support.
[ruby-core:35572]

* ext/socket/lib/socket.rb (connect_nonblock): use IO#wait_writable
* lib/drb/drb.rb (DRB::DRbTCPSocket#alive?): use IO#wait_readable
* lib/webrick/httpserver.rb (run): ditto
* lib/resolv.rb (request): ditto for single socket case
  [ruby-core:68943] [Feature #11081]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-06 20:30:43 +00:00
nobu 466bd05fda resolv.rb: fix equality
* lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements
  returned by Kernel#instance_variables are Symbols now.
  [ruby-core:68128] [Bug #10857]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-17 02:47:19 +00:00
normal 89ba151440 lib/resolv.rb: consider ENETUNREACH as ResolvTimeout
This allows "gem install /path/to/local.gem" to be successful
on a machine without a network connection.

[ruby-core:67411] [Bug #10712]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-07 22:19:19 +00:00
akr ec7f1f5dc2 * lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
(Resolv::DNS::Name#initialize): Normalize labels as
  Resolv::DNS::Label::Str objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-02 00:10:04 +00:00
nobu 54bd85d19d resolv.rb: String#b
* lib/resolv.rb (Resolv::DNS::Label::Str#initialize): use String#b.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-31 14:59:19 +00:00
akr 6cf00e15f8 * lib/resolv.rb (Resolv::DNS::Label::Str#initialize): Set encoding
ASCII-8BIT before downcase.  case insensivity of DNS labels doesn't
  apply non-ASCII characters.  [RFC 4343]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-31 08:50:10 +00:00
akr e36d40f923 * lib/resolv.rb (Resolv::DNS::Name#==): Compare an array of Label:Str
objects.  Label#Str#== is case-insensitive.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-31 04:45:05 +00:00
nobu 69a7bb31f9 resolv.rb: case-insensitive comparison
* lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the
  comparison should be case-insensitive as well.
  [ruby-core:66498] [Bug #10550]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-30 07:16:14 +00:00
nobu a0325ea704 resolv.rb: dots differences
* lib/resolv.rb (Resolv::DNS::Name): names with different dots
  should be different.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-30 07:03:47 +00:00
tenderlove 570c028c7e * lib/resolv.rb: fall back if canonicalization fails.
Thanks Vit Ondruch for the patch!  [ruby-core:65836]

* test/resolv/test_dns.rb: test for patch

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-21 20:04:27 +00:00
normal 9bb7dfa247 normalize reference to Timeout::Error
From: John Bachir <j@jjb.cc>

* bootstraptest/test_io.rb (assert_finish):
  normalize rescue for Timeout::Error
* lib/net/ftp.rb (Net#read_timeout): ditto for doc
* lib/resolv.rb (Resolv::ResolvTimeout): ditto for subclass
* lib/webrick/httprequest.rb (_read_data): ditto for rescue
* sample/timeout.rb (p timeout): ditto for call
* test/drb/drbtest.rb (test_06_timeout): ditto
* test/ruby/test_readpartial.rb (test_open_pipe): ditto
* test/thread/test_queue.rb (test_queue_thread_raise): ditto
* thread.c (rb_thread_s_handle_interrupt): ditto for doc
  [ruby-core:65481] [misc #10339]

TimeoutError is a legacy constant, Timeout::Error is the canonical constant.
This patch normalizes all code and comments to reference Timeout::Error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-07 20:00:09 +00:00
hsbt 4f7449beba * lib/gserver.rb: remove redundant use of to_s in interpolation.
* lib/logger.rb: ditto.
* lib/optparse.rb: ditto.
* lib/rbconfig/obsolete.rb: ditto.
* lib/resolv.rb: ditto.
* lib/webrick/httpresponse.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 08:48:46 +00:00
akr db537c5181 * lib/resolv.rb (bind_random_port): Rescue EPERM for FreeBSD which
security.mac.portacl.port_high is changed.
  See mac_portacl(4) for details.
  Reported by Jakub Szafranski.  [ruby-core:60917] [Bug #9544]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-22 17:38:57 +00:00
akr f01b5e217b * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder#get_labels):
Make it iterative.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-08 07:35:24 +00:00
akr 5323328f0c * lib/resolv.rb: Don't set CLOEXEC flag explicitly. (Ruby set it by
default.)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-08 06:42:28 +00:00
akr 25a89ac0ac * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise
DecodeError if no data before the limit.
  Reported by Will Bryant.  [ruby-core:60557] [Bug #9498]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-08 06:29:54 +00:00
akr 688606d2d9 * lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on
socket creation.
  Reported by Bjoern Rennhak.  [ruby-core:60442] [Bug #9477]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-07 15:03:34 +00:00
akr e86a90420d * lib/resolv.rb (Resolv::DNS::Resource::TXT#data): Return concatenated
string.
  Patch by Ryan Brunner.  [ruby-core:58220] [Bug #9093]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18 14:01:43 +00:00
nobu 1ffbe07e17 resolv.rb: no encodings
* lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not
  consider encodings in hosts file.  [ruby-core:59239] [Bug #9273]
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-21 03:37:26 +00:00
a_matsuda ba672b6de1 * lib/resolv.rb: Fix typo in an error message
s/postive/positive/

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-12 06:17:31 +00:00
nobu 0712483fdd resolv.rb: workaround for recent Rubygems
* lib/resolv.rb (Resolv::Hosts): get rid of load error in require
  which causes recent Rubygems to build all extension libraries.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 08:03:32 +00:00
zzak c366a99cc5 * lib/cgi.rb: [DOC] Capitalize "Ruby" in documentation [Fixes GH-341]
Patch by Dave Worth https://github.com/ruby/ruby/pull/341
* lib/webrick.rb: ditto
* lib/scanf.rb: ditto
* lib/xmlrpc/config.rb: ditto
* lib/resolv.rb: ditto
* lib/e2mmap.rb: ditto
* lib/fileutils.rb: ditto
* lib/mkmf.rb: ditto
* lib/cgi/session.rb: ditto
* lib/yaml.rb: ditto
* lib/erb.rb: ditto
* lib/irb.rb: ditto
* lib/tracer.rb: ditto
* lib/net/http.rb: ditto
* ext/syslog/lib/syslog/logger.rb: ditto
* sample/pty/expect_sample.rb: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 13:50:32 +00:00
akr 672490d08c * lib/resolv.rb (MDNSOneShot#sender): Delete an unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-07 01:42:18 +00:00
akr c4d8cc4eae * lib/resolv.rb: Support LOC resources.
[ruby-core:23361] [Feature #1436] by JB Smith.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 14:52:48 +00:00
akr 9791353555 * lib/resolv.rb: Add one-shot multicast DNS support.
[ruby-core:53387] [Feature #8089] by Eric Hodel.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 14:32:34 +00:00
akr 4c1e97226f * lib/resolv.rb (Resolv::DNS.fetch_resource): New method to obtain
full result.
  [ruby-dev:43587] [Feature #4788] proposed by Makoto Kishimoto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 13:16:36 +00:00
akr dc5b184b1f * lib/resolv.rb (bind_random_port): Rescue EACCES for SunOS.
bind() on SunOS for port 2049 (nfs) and 4045 (lockd) causes
  EACCES with unprivileged process.  cf. PRIV_SYS_NFS in privileges(5)
  [ruby-core:48064] [Bug #7183] reported by Frank Meier.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 14:55:36 +00:00