mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-04 03:27:23 -05:00 
			
		
		
		
	fuzz: Don't call Load() in HTTP caddyfile adapter fuzz tests
Doing so has a tendency to request certificates...
This commit is contained in:
		
							parent
							
								
									dccba71276
								
							
						
					
					
						commit
						1be121cec7
					
				@ -18,9 +18,6 @@
 | 
				
			|||||||
package httpcaddyfile
 | 
					package httpcaddyfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/caddyserver/caddy/v2"
 | 
					 | 
				
			||||||
	"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
 | 
						"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -28,7 +25,9 @@ func FuzzHTTPCaddyfileAdapter(data []byte) int {
 | 
				
			|||||||
	adapter := caddyfile.Adapter{
 | 
						adapter := caddyfile.Adapter{
 | 
				
			||||||
		ServerType: ServerType{},
 | 
							ServerType: ServerType{},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	b, warns, err := adapter.Adapt(data, nil)
 | 
					
 | 
				
			||||||
 | 
						_, warns, err := adapter.Adapt(data, nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Adapt func calls the Setup() func of the ServerType,
 | 
						// Adapt func calls the Setup() func of the ServerType,
 | 
				
			||||||
	// thus it's going across multiple layers, each can
 | 
						// thus it's going across multiple layers, each can
 | 
				
			||||||
	// return warnings or errors. Marking the presence of
 | 
						// return warnings or errors. Marking the presence of
 | 
				
			||||||
@ -36,14 +35,9 @@ func FuzzHTTPCaddyfileAdapter(data []byte) int {
 | 
				
			|||||||
	// could push the fuzzer towards a path where we only
 | 
						// could push the fuzzer towards a path where we only
 | 
				
			||||||
	// catch errors. Let's push the fuzzer to where it passes
 | 
						// catch errors. Let's push the fuzzer to where it passes
 | 
				
			||||||
	// but breaks.
 | 
						// but breaks.
 | 
				
			||||||
	if (err != nil) || (warns != nil && len(warns) > 0) {
 | 
						if err != nil || (warns != nil && len(warns) > 0) {
 | 
				
			||||||
		return 0
 | 
							return 0
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// adapted Caddyfile should be parseable by the configuration loader in admin.go
 | 
					 | 
				
			||||||
	err = caddy.Load(bytes.NewReader(b))
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return 0
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 1
 | 
						return 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user