audit: fixing panic caused by tls connection state. Fixes #322

This commit is contained in:
Armon Dadgar 2015-06-29 17:16:17 -07:00
parent 4776825e20
commit b49683a40b
2 changed files with 40 additions and 0 deletions

View file

@ -53,6 +53,16 @@ func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr
return err
}
if !b.LogRaw {
// Before we copy the structure we must nil out some data
// otherwise we will cause reflection to panic and die
if req.Connection != nil && req.Connection.ConnState != nil {
origState := req.Connection.ConnState
req.Connection.ConnState = nil
defer func() {
req.Connection.ConnState = origState
}()
}
// Copy the structures
cp, err := copystructure.Copy(auth)
if err != nil {
@ -88,6 +98,16 @@ func (b *Backend) LogResponse(
return err
}
if !b.LogRaw {
// Before we copy the structure we must nil out some data
// otherwise we will cause reflection to panic and die
if req.Connection != nil && req.Connection.ConnState != nil {
origState := req.Connection.ConnState
req.Connection.ConnState = nil
defer func() {
req.Connection.ConnState = origState
}()
}
// Copy the structure
cp, err := copystructure.Copy(auth)
if err != nil {

View file

@ -54,6 +54,16 @@ type Backend struct {
func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr error) error {
if !b.logRaw {
// Before we copy the structure we must nil out some data
// otherwise we will cause reflection to panic and die
if req.Connection != nil && req.Connection.ConnState != nil {
origState := req.Connection.ConnState
req.Connection.ConnState = nil
defer func() {
req.Connection.ConnState = origState
}()
}
// Copy the structures
cp, err := copystructure.Copy(auth)
if err != nil {
@ -91,6 +101,16 @@ func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr
func (b *Backend) LogResponse(auth *logical.Auth, req *logical.Request,
resp *logical.Response, err error) error {
if !b.logRaw {
// Before we copy the structure we must nil out some data
// otherwise we will cause reflection to panic and die
if req.Connection != nil && req.Connection.ConnState != nil {
origState := req.Connection.ConnState
req.Connection.ConnState = nil
defer func() {
req.Connection.ConnState = origState
}()
}
// Copy the structure
cp, err := copystructure.Copy(auth)
if err != nil {