[lxc-devel] [lxd/master] lxd/images: Fix crash when no "info" struct

stgraber on Github lxc-bot at linuxcontainers.org
Tue Oct 6 19:47:00 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 648 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201006/1643d1bb/attachment.bin>
-------------- next part --------------
From fa9f3d3f4352d9c570e0ae97e41e2319297286d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 6 Oct 2020 15:40:43 -0400
Subject: [PATCH] lxd/images: Fix crash when no "info" struct
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This fixes a crash happening when all of those conditions are met:
 - Clustered environment
 - Image is downloaded using the LXD protocol
 - Source image is marked as private
 - Image was downloaded previously to the cluster
 - The server processing the download doesn't have the image

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/daemon_images.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxd/daemon_images.go b/lxd/daemon_images.go
index d17e523d28..7e272a3a89 100644
--- a/lxd/daemon_images.go
+++ b/lxd/daemon_images.go
@@ -119,13 +119,13 @@ func (d *Daemon) ImageDownload(op *operations.Operation, server string, protocol
 
 		if nodeAddress != "" {
 			// The image is available from another node, let's try to import it.
-			err = instanceImageTransfer(d, project, info.Fingerprint, nodeAddress)
+			err = instanceImageTransfer(d, project, imgInfo.Fingerprint, nodeAddress)
 			if err != nil {
 				return nil, errors.Wrapf(err, "Failed transferring image")
 			}
 
 			// As the image record already exists in the project, just add the node ID to the image.
-			err = d.cluster.AddImageToLocalNode(project, info.Fingerprint)
+			err = d.cluster.AddImageToLocalNode(project, imgInfo.Fingerprint)
 			if err != nil {
 				return nil, errors.Wrapf(err, "Failed adding image to local node")
 			}


More information about the lxc-devel mailing list