From nobody Thu May 2 22:31:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154162508561732.17543497013867; Wed, 7 Nov 2018 13:11:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F3063962; Wed, 7 Nov 2018 21:11:22 +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 CFB785D73F; Wed, 7 Nov 2018 21:11:19 +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 500B84BB79; Wed, 7 Nov 2018 21:11:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA7Kvm7C018953 for ; Wed, 7 Nov 2018 15:57:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5A23C18516; Wed, 7 Nov 2018 20:57:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 524474242 for ; Wed, 7 Nov 2018 20:57:45 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75D30394D2C for ; Wed, 7 Nov 2018 20:57:44 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id r71so22878577qkr.10 for ; Wed, 07 Nov 2018 12:57:44 -0800 (PST) Received: from localhost.localdomain ([2804:431:b705:d444:68fc:9ba9:baa0:f99a]) by smtp.gmail.com with ESMTPSA id b17sm1068565qkj.69.2018.11.07.12.57.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 12:57:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=KxbEo43aNlJAdSbWlsD18NCn65NfCMxmdpqLCFh9/F4=; b=FpE8BF3WXAXKBPDCFVEJcI+oUwjPItxI+upmqhX/NglDKkzelMUCYKStzh0Gs2jNkz +JKZhxohe3FjrRM/kP9SAsHDfl9FYlH7cjTBFBqeb1vvwzPi57yBR5O1b16OLPPlhhZK tSEEpsXRDYg3NWvKM8uhgV90Zw6K9wjgwY/2KNN6A6gzrhc3S8PnrTOnvb0fL4e9Bcj4 tq12R695Qpa4RtNR57Fpp6I8J+0RWLbXxjirl4rneQo1mQ52CrbB7MlZqyH8w4obnVdP KeIYjmculC/BVuf6x3glus+x5ecC8Hp8LMXeFujDKtUvnsqOt4AIzZzaOp34w5sFFbyu owYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=KxbEo43aNlJAdSbWlsD18NCn65NfCMxmdpqLCFh9/F4=; b=f8oNsDPszimwutf9yMrMZnujz0jCDCcnWzDCvhkYzu46iu1bMVHfatmRbhhmxFHSer 8qVUXaF37Y6JFYER0fMdwfCHE2rKuv0clZOcNDM61Ur5CNCdjNbZEjTUyH6bj5/7eyIy 8DVJvbf6PE+KcsPtAhmL1BCTAZaGQiVwqzAedksFfOONElKpI64EuZN8BNucybgDpvxN wB8BoneGurs0QQiayOarbhlgc7eDsfYhQDOOXTA04FlKXXACcMNLX0Iq6McuZENO7mfb wDEsDm1EcZHcCCstzIwkiqJjSMroeh1NF2BDa4wv1AXLmd61EoWwCln7I4ZA/tyZgP1R /LMQ== X-Gm-Message-State: AGRZ1gK1RM0GMLRCjNFkzisOt6neEwF7eaFmy+38h3Z3iesj2MlYkyMn c7+qMOFVYmjGBiwZNzehJ8PgkrDJmV0= X-Google-Smtp-Source: AJdET5cSxUfTBF+CPAhY0KddZF0YP2ZkinAlIuWAcACC9R+AAlTCkpOD53LLSn/4UDy+wbzEZO4ZPg== X-Received: by 2002:a0c:8425:: with SMTP id l34mr1874921qva.101.1541624263205; Wed, 07 Nov 2018 12:57:43 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Wed, 7 Nov 2018 18:57:02 -0200 Message-Id: <20181107205702.14057-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 07 Nov 2018 20:57:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 07 Nov 2018 20:57:44 +0000 (UTC) for IP:'209.85.222.196' DOMAIN:'mail-qk1-f196.google.com' HELO:'mail-qk1-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.222.196 mail-qk1-f196.google.com 209.85.222.196 mail-qk1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] lxc: Clang is complaining about possible NULL pointer. 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 07 Nov 2018 21:11:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The array "mount" inside lxc_container is not being checked before for loop. Clang syntax scan is complaining about this segmentation fault. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_container.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 918194dacd..d834bf01d7 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -867,9 +867,13 @@ static int lxcContainerSetReadOnly(void) } } =20 - if (mounts) - qsort(mounts, nmounts, sizeof(mounts[0]), - virStringSortRevCompare); + if (!mounts) { + ret =3D 0; + goto cleanup; + } + + qsort(mounts, nmounts, sizeof(mounts[0]), + virStringSortRevCompare); =20 for (i =3D 0; i < nmounts; i++) { VIR_DEBUG("Bind readonly %s", mounts[i]); @@ -883,9 +887,7 @@ static int lxcContainerSetReadOnly(void) =20 ret =3D 0; cleanup: - for (i =3D 0; i < nmounts; i++) - VIR_FREE(mounts[i]); - VIR_FREE(mounts); + virStringListFreeCount(mounts, nmounts); endmntent(procmnt); return ret; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list