From nobody Fri Apr 26 03:04:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 158108753468231.246190793807614; Fri, 7 Feb 2020 06:58:54 -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-35-Cn_DF-3SM2--Al0QXDZgYw-1; Fri, 07 Feb 2020 09:58:51 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 02C8A1081FA0; Fri, 7 Feb 2020 14:58:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E5D38DC1B; Fri, 7 Feb 2020 14:58:44 +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 D61F8180880C; Fri, 7 Feb 2020 14:58:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 017EwfFi005435 for ; Fri, 7 Feb 2020 09:58:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CCCB60C05; Fri, 7 Feb 2020 14:58:41 +0000 (UTC) Received: from dhcp-16-105.lcy.redhat.com (unknown [10.42.16.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BF5460BF7; Fri, 7 Feb 2020 14:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581087533; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=FlYyBFstHjXsUSQtD5s8eK/k97qtj/2Xxwl7hdoyxXQ=; b=KzzuCmIIp3HDHBcK7RU929SnfGxfyb5MXH5yVZOtKg2zBAYU8rfYWobNrWzKGLleVxHQvH i5A9RrvpmKBSlGDbNURo5w5/IdD2QSdZFdH1mbq7Vc6cT1MnCMIBrz33R73YuZugYQY+bn q1I9cnCXEj58q65w4nCgVlqZNuIXLEw= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] tests: avoid referencing stale readdir pointer Date: Fri, 7 Feb 2020 14:58:36 +0000 Message-Id: <20200207145836.2783142-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@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.13 X-MC-Unique: Cn_DF-3SM2--Al0QXDZgYw-1 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" The contents of 'struct dirent' are only valid until the next call to readdir() or closedir(). It is thus invalid to save a pointer to the 'd_name' field. Somehow this hasn't affected the test suite until recently when FreeBSD 12 started showing use of uninitialized memory resulting in test failures. Signed-off-by: Daniel P. Berrang=C3=A9 --- Pushed as a build fix tests/testutilsqemu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index c17e284930..0cb9a7456d 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -497,7 +497,7 @@ testQemuGetLatestCapsForArch(const char *arch, char *tmp =3D NULL; unsigned long maxver =3D 0; unsigned long ver; - const char *maxname =3D NULL; + g_autofree char *maxname =3D NULL; char *ret =3D NULL; =20 fullsuffix =3D g_strdup_printf("%s.%s", arch, suffix); @@ -522,7 +522,8 @@ testQemuGetLatestCapsForArch(const char *arch, } =20 if (ver > maxver) { - maxname =3D ent->d_name; + g_free(maxname); + maxname =3D g_strdup(ent->d_name); maxver =3D ver; } } --=20 2.24.1