From nobody Sun Feb 8 11:53:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158095518836324.113187769192564; Wed, 5 Feb 2020 18:13:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-cL-qsKwxPGOtVfDskLSgOg-1; Wed, 05 Feb 2020 21:13:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE86F1137843; Thu, 6 Feb 2020 02:12:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A4F888858; Thu, 6 Feb 2020 02:12:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4213585CF8; Thu, 6 Feb 2020 02:12:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0162CLRU001400 for ; Wed, 5 Feb 2020 21:12:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id A0B1510A859A; Thu, 6 Feb 2020 02:12:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CAA610A85AE for ; Thu, 6 Feb 2020 02:12:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6E5C801E9B for ; Thu, 6 Feb 2020 02:12:17 +0000 (UTC) Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-TuX85X_lPWGHpfGu4pwZ9A-1; Wed, 05 Feb 2020 21:12:13 -0500 Received: by mail-qv1-f65.google.com with SMTP id p2so2139720qvo.10; Wed, 05 Feb 2020 18:12:13 -0800 (PST) Received: from localhost.localdomain ([2804:431:c7ca:a5ab:a101:b6c3:81ed:d299]) by smtp.gmail.com with ESMTPSA id h9sm851310qtq.61.2020.02.05.18.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 18:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580955187; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8Y0VEk3l+QgSuEL/upYzMPJ1f8BU34yyU9wCauouD64=; b=KiHcefMyDi8XA/YjXxDfvWevhZh0OcxSaGVfZrRFYrcPo0w6LqV192p1TEgdI64sXRhROP g0NG7q49ZqXU/90zrrAZHXJjjIerarwzhsm5CeyNK9HsL8v3yzxMqp1Km0YlfZT7GRj0Jp ZmEuY9wFAZm2GOCeTvytFiUFsVmK6MY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vim0QTuBq3E0+rBqF2xNkAiCHCoBxgWSJF8nWA22Xm8=; b=XLUkxU68RLQ6KF1yuHxfat778ALksypbvLhJ0m+FJ1ahcu64YVX8SaysuoJa9IcFyl 77y2JtInnMijvqBwF1DD1XpNrBbxZmNHGktVFJyzORtmCvdg+F2LmbZkoMyZ53VCobfJ u2iwu0MKNS32qgnPltPgj7NHtJBEhcHHhmvhV9TYEy+/22PBhMCfopq82W1A7Zwnp7Rj zwzyKdf7WopaV5CN8PNpfRIvr85uL5GnZcbVYYwvxrrUnXq6zjIu4ALF7CpFUMH2hZ0F IitF9O7LvIPuhMT5GfISvt5g4hK7G8dIW03jiVkMqY+Fvb0qZp7nJqc1e6hkb4FN9Gpf ghXw== X-Gm-Message-State: APjAAAXC+/tZbHCdOTMrmwfI8/maA601dEXQjC3SmFwBW+kxh9MQ2XJc G236K3LqbLK5raFjPTRESHExF9/e X-Google-Smtp-Source: APXvYqzAqYqUCBCoK0+CBkHI4bb+7KS+pEgKBdOCcyEmBAtgrnZ1dljRIoThVU+1d7Rviwrrj3wYbQ== X-Received: by 2002:a0c:f28f:: with SMTP id k15mr537814qvl.76.1580955132336; Wed, 05 Feb 2020 18:12:12 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Subject: [PATCH] lxc: Fix segfault when lxc.network does not start with 'type' Date: Wed, 5 Feb 2020 23:12:05 -0300 Message-Id: <20200206021205.15424-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-MC-Unique: TuX85X_lPWGHpfGu4pwZ9A-1 X-MC-Unique: cL-qsKwxPGOtVfDskLSgOg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0162CLRU001400 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" To configure network settings using config file, legacy LXC settings require starting them with 'lxc.network.type' entry. If someone accidentally starts with 'lxc.network.name', libvirt will crash with segfault. This patch checks if this case is happening. Sample invalid settings: lxc.network.link =3D eth0 lxc.network.type =3D phys lxc.network.name =3D eth1 lxc.network.ipv4 =3D 192.168.122.2/24 lxc.network.ipv4.gateway =3D 192.168.122.1 Now, libvirt only see error without segmentation fault. Signed-off-by: Julio Faracco --- src/lxc/lxc_native.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 59f3dd4fee..5462b74b85 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -717,7 +717,11 @@ lxcNetworkGetParseDataByIndexLegacy(lxcNetworkParseDat= aArray *networks, } =20 /* Return last element added like a stack. */ - return networks->parseData[ndata - 1]; + if (networks->ndata > 0) + return networks->parseData[ndata - 1]; + + /* Not able to retrive an element */ + return NULL; } =20 =20 --=20 2.20.1