Browse Source

Linode SD: cast InstanceSpec values to int64 to avoid overflows

InstanceSpec struct members are untyped integers, so they can overflow
on 32-bit arch when bit-shifted left.

Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
pull/12568/head
Daniel Swarbrick 1 year ago
parent
commit
de89a8c827
No known key found for this signature in database
GPG Key ID: C346A9571DD986F5
  1. 6
      discovery/linode/linode.go

6
discovery/linode/linode.go

@ -304,10 +304,10 @@ func (d *Discovery) refreshData(ctx context.Context) ([]*targetgroup.Group, erro
linodeLabelGroup: model.LabelValue(instance.Group),
linodeLabelHypervisor: model.LabelValue(instance.Hypervisor),
linodeLabelBackups: model.LabelValue(backupsStatus),
linodeLabelSpecsDiskBytes: model.LabelValue(fmt.Sprintf("%d", instance.Specs.Disk<<20)),
linodeLabelSpecsMemoryBytes: model.LabelValue(fmt.Sprintf("%d", instance.Specs.Memory<<20)),
linodeLabelSpecsDiskBytes: model.LabelValue(fmt.Sprintf("%d", int64(instance.Specs.Disk)<<20)),
linodeLabelSpecsMemoryBytes: model.LabelValue(fmt.Sprintf("%d", int64(instance.Specs.Memory)<<20)),
linodeLabelSpecsVCPUs: model.LabelValue(fmt.Sprintf("%d", instance.Specs.VCPUs)),
linodeLabelSpecsTransferBytes: model.LabelValue(fmt.Sprintf("%d", instance.Specs.Transfer<<20)),
linodeLabelSpecsTransferBytes: model.LabelValue(fmt.Sprintf("%d", int64(instance.Specs.Transfer)<<20)),
}
addr := net.JoinHostPort(publicIPv4, strconv.FormatUint(uint64(d.port), 10))

Loading…
Cancel
Save