mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	* fuzz: some cleanups Signed-off-by: Miek Gieben <miek@miek.nl> * smaller Signed-off-by: Miek Gieben <miek@miek.nl> * documentation Signed-off-by: Miek Gieben <miek@miek.nl> * comments Signed-off-by: Miek Gieben <miek@miek.nl>
		
			
				
	
	
		
			28 lines
		
	
	
		
			539 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			539 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package fuzz contains functions that enable fuzzing of plugins.
 | |
| package fuzz
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"github.com/coredns/coredns/plugin"
 | |
| 	"github.com/coredns/coredns/plugin/test"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| // Do will fuzz p - used by gofuzz. See Makefile.fuzz for comments and context.
 | |
| func Do(p plugin.Handler, data []byte) int {
 | |
| 	ctx := context.TODO()
 | |
| 	ret := 1
 | |
| 	r := new(dns.Msg)
 | |
| 	if err := r.Unpack(data); err != nil {
 | |
| 		ret = 0
 | |
| 	}
 | |
| 
 | |
| 	if _, err := p.ServeDNS(ctx, &test.ResponseWriter{}, r); err != nil {
 | |
| 		ret = 1
 | |
| 	}
 | |
| 
 | |
| 	return ret
 | |
| }
 |