fix nil deref in exec admission

pull/6/head
Seth Jennings 2017-01-30 13:51:00 -06:00
parent 722c8b065a
commit 071c66a011
1 changed files with 2 additions and 2 deletions

View File

@ -110,7 +110,7 @@ func (d *denyExec) Admit(a admission.Attributes) (err error) {
// isPrivileged will return true a pod has any privileged containers
func isPrivileged(pod *api.Pod) bool {
for _, c := range pod.Spec.InitContainers {
if c.SecurityContext == nil {
if c.SecurityContext == nil || c.SecurityContext.Privileged == nil {
continue
}
if *c.SecurityContext.Privileged {
@ -118,7 +118,7 @@ func isPrivileged(pod *api.Pod) bool {
}
}
for _, c := range pod.Spec.Containers {
if c.SecurityContext == nil {
if c.SecurityContext == nil || c.SecurityContext.Privileged == nil {
continue
}
if *c.SecurityContext.Privileged {