Skip to content

Commit f17cce3

Browse files
Check for nil before deferencing pointer in SG config
Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
1 parent 4291b59 commit f17cce3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/amazonec2/amazonec2.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -866,13 +866,15 @@ func (d *Driver) configureSecurityGroupPermissions(group *ec2.SecurityGroup) []*
866866
hasDockerPort := false
867867
hasSwarmPort := false
868868
for _, p := range group.IpPermissions {
869-
switch *p.FromPort {
870-
case 22:
871-
hasSshPort = true
872-
case int64(dockerPort):
873-
hasDockerPort = true
874-
case int64(swarmPort):
875-
hasSwarmPort = true
869+
if p.FromPort != nil {
870+
switch *p.FromPort {
871+
case 22:
872+
hasSshPort = true
873+
case int64(dockerPort):
874+
hasDockerPort = true
875+
case int64(swarmPort):
876+
hasSwarmPort = true
877+
}
876878
}
877879
}
878880

0 commit comments

Comments
 (0)