mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	[ruby/resolv] Fix confusion of received response message
This is a follow up for commit 33fb966197f1 ("Remove sender/message_id
pair after response received in resolv", 2020-09-11).
As the @senders instance variable is also used for tracking transaction
ID allocation, simply removing an entry without releasing the ID would
eventually deplete the ID space and cause
Resolv::DNS.allocate_request_id to hang.
It seems the intention of the code was to check that the received DNS
message is actually the response for the question made within the method
earlier. Let's have it actually do so.
[Bug #12838] https://bugs.ruby-lang.org/issues/12838
[Bug #17748] https://bugs.ruby-lang.org/issues/17748
53ca9c9209
			
			
This commit is contained in:
		
							parent
							
								
									5b0abba931
								
							
						
					
					
						commit
						9edc162583
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -696,17 +696,17 @@ class Resolv
 | 
			
		|||
          rescue DecodeError
 | 
			
		||||
            next # broken DNS message ignored
 | 
			
		||||
          end
 | 
			
		||||
          if s = sender_for(from, msg)
 | 
			
		||||
          if sender == sender_for(from, msg)
 | 
			
		||||
            break
 | 
			
		||||
          else
 | 
			
		||||
            # unexpected DNS message ignored
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
        return msg, s.data
 | 
			
		||||
        return msg, sender.data
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def sender_for(addr, msg)
 | 
			
		||||
        @senders.delete([addr,msg.id])
 | 
			
		||||
        @senders[[addr,msg.id]]
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def close
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue