From patchwork Tue Mar 12 18:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779769 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2168040wrt; Tue, 12 Mar 2024 11:39:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+4CxLjpW5xIYJHXSaxt/V+XUZoVDlnmG6b7jOOZqgWmkT2pWp82F8TCK6wTR0+Sr+4qKXHVa4HAqfpDQ34ffN X-Google-Smtp-Source: AGHT+IHt/Cbm4qH+YKF9dSC1jNYWMfqLahGLzW8I3WvuvG3fl5DhT7XtsM5ctFPW8hgNGFA1TEqc X-Received: by 2002:a05:620a:1664:b0:788:20d8:f2e6 with SMTP id d4-20020a05620a166400b0078820d8f2e6mr4383337qko.18.1710268754339; Tue, 12 Mar 2024 11:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710268754; cv=none; d=google.com; s=arc-20160816; b=LB6JEZv42we7TZvNCjHCujMqNIcx1jnP/Fed7fpIvU1JBGm3YisNY6ekeEBFQog5n6 3zIGLxWYDF4/dExHZOjKmeRaIetVcN1hl5OY+osmasC4rU5n+51BCYHVDIGqEn1+i9gB ufpJO09t03IU+r9b40AATz86g6VtALTtfTViOu6Jq/OCApn85HL0GPGWVoG7aGSzs9Zg Bn27eN2XCdQICXiUyHPRFP5HlWyOmdMSIWC553dCJynWFt2KWpdTbIHijYmG1N6I9VsB pLClSoEK+WhhdUij6l3E1OtuzRB3SALkphKKssdlUmzjtednSf0k7cIKigLhHcqoYVty 33nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=F5TgssMb195QO0ZRrXOaRa+rjmUvH1NGzSH3Wll6Fnw=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=xUgQ7HC6DAZe14Oco3Wz/wFyG0qhe7K7bk91PHLG1hk32iphEVgzXK4YxX9nzsMvV+ v8ANgAU/DKuvLAH3ws23iLO7sh+3DBAVaLv+frPechTr33VPdT4n3TTb5Hln94yCaCax 9zprPyq43tNc0e9VMyM0xpYLf582sQ7gLyuKUFRAjpa/O6RbOwdjLi8kqabCPv3q5QY0 Vev3AbbUNwM9hN2CJj36lRdxioQ7xxSYfFOm1EKCXi//5HYuUeNmRqlbPThIkkNe2ciy 3F3FhL3U2ru/oR81eTC92wpTZKg5RHD9tO1tSX4W54WbjvgBX90ICi/UyAOQHlSzSgxf a+cw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMfWKLE5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l5-20020a05620a210500b0078834291811si7813385qkl.278.2024.03.12.11.39.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 11:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMfWKLE5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk71D-0003Wo-Jz; Tue, 12 Mar 2024 14:38:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk710-0003N6-8A for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:19 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70x-0000cW-MO for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:18 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4133100bccdso9412895e9.0 for ; Tue, 12 Mar 2024 11:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268694; x=1710873494; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=F5TgssMb195QO0ZRrXOaRa+rjmUvH1NGzSH3Wll6Fnw=; b=hMfWKLE5AxQwmn41SKLaRp/xO5wwJwTHhSFHLkoSTBACEurGgfsK4OSWP2/WQDzj/o xFS8YMg/lqbQ0mYGy9pc3zSvStea9TDx6SwbAcT4ITTevnm0mo50YTNRnQVzzC7cjmGI j1eU5RU3MJZcU/GKls4+CsukvBeT23fuh+2SV7JSQ8pl13DhWOvZvVF0AgXnwZsdh2He W4xQa2vZsqbtkn18sOuIONjTUbYvLC4q4PdvXFIJWOWHzTwQlcK2ItNR+TlOQFJMukz6 ERWBb+dAAMu5xeQCSkWJTvDfWHdwN903B2UHSppZv6a4ARLBEvWGQvvjX3c2GwU5i18R gF6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268694; x=1710873494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F5TgssMb195QO0ZRrXOaRa+rjmUvH1NGzSH3Wll6Fnw=; b=Kj0/XY/asZPKMozyFlJmseRST33MJv4+dN5VVGTo0tbnVu1d50yr2QU6XN9eqG7hyO cl4Zzc0VS7ixae2TJla8qEvGSlHKAh1i4CnSQVdM2MkpPaCAxo5FJ1VxuF0swKrq1m2j kP4har9DK9kzUFGVOrpxt9d49ghglLqlsyrIUAWDqi74xt5/KiY+F8mV3OVLgYZYK8ep N1kK+d5dK7TKOp78sS+eK5hZPkZEKrH87C5FmsZpXAVW2xQWKNBap8mTCjDVcKig/Olb 7Rm+f8iJH0n8qrk2ePWEwHWBoCJx1HnCLg5ubGs8b5bWgEOW3hZU7ht4jRZvSc5sQR8j ofMQ== X-Gm-Message-State: AOJu0YwesTITl9eR1QERaosJTmhSZv/gEMrn1lpLgWdC39lRU6r9tJzF 6SMPUtV6s6LRkk4WQTHrNxeKNH88ZuqGa0RvUldGEdf19nSO7kvi8oNULClyIDNqIFlxpQEVGjn 7 X-Received: by 2002:a05:600c:1d12:b0:413:2ea4:1731 with SMTP id l18-20020a05600c1d1200b004132ea41731mr3970648wms.15.1710268694341; Tue, 12 Mar 2024 11:38:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 7/7] tests/qtest/libqtest.c: Check for g_setenv() failure Date: Tue, 12 Mar 2024 18:38:10 +0000 Message-Id: <20240312183810.557768-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Coverity points out that g_setenv() can fail and we don't check for this in qtest_inproc_init(). In practice this will only fail if a memory allocation failed in setenv() or if the caller passed an invalid architecture name (e.g. one with an '=' in it), so rather than requiring the callsite to check for failure, make g_setenv() failure fatal here, similarly to what we did in commit aca68d95c515. Resolves: Coverity CID 1497485 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/libqtest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index f33a2108610..d8f80d335e7 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1814,7 +1814,11 @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, * way, qtest_get_arch works for inproc qtest. */ gchar *bin_path = g_strconcat("/qemu-system-", arch, NULL); - g_setenv("QTEST_QEMU_BINARY", bin_path, 0); + if (!g_setenv("QTEST_QEMU_BINARY", bin_path, 0)) { + fprintf(stderr, + "Could not set environment variable QTEST_QEMU_BINARY\n"); + exit(1); + } g_free(bin_path); return qts;