From nobody Mon Feb 9 02:51:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666891993; cv=none; d=zohomail.com; s=zohoarc; b=nYCjn20CEOMkC4wZVu9DTLzOSy6U49S2JVYU7yy22ijH5v/ZUXc7DlHwxjyzv6hptkj3YNDFtZAE5k5JpNwRPh67v9Rs+BXCue6CW72qhHcb38vNA+xTIe7qHzctE3AbDFEiXfHpofbQkXlL1sSZzD2ridr8OvhGWPtuvgWB9e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666891993; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ij9w/bGIBYGmtlU330WRSDH1uMJbMYD/pLaqzryDzZc=; b=nbvAe4X0jQQfP5DkRPn64sqNUZ890NrNABJWvmib8sJ3bqnaw56pQrBBHTn6EKhiSH6ytEwhWjkIHAt7jEq50ANTy6fxt543DHDXAFYr7vplOmKcnu7sOMnrpOT/daGZGwEVFSbJJMaPeBhW9mFmsWy1wTDHkRUxUwjPxF6DUFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666891993448367.63344183305776; Thu, 27 Oct 2022 10:33:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo6jL-0005z0-71; Thu, 27 Oct 2022 13:31:47 -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 1oo6jJ-0005sq-M2 for qemu-devel@nongnu.org; Thu, 27 Oct 2022 13:31:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo6jI-0000wn-8m for qemu-devel@nongnu.org; Thu, 27 Oct 2022 13:31:45 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-wuiEIaB7PZKZVIP56xUwwg-1; Thu, 27 Oct 2022 13:31:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DCA92801A58; Thu, 27 Oct 2022 17:31:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 838B640C6EC3; Thu, 27 Oct 2022 17:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666891903; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=Ij9w/bGIBYGmtlU330WRSDH1uMJbMYD/pLaqzryDzZc=; b=Ha6GVCsM+gH0POHlscN1GAHeQTNGSlYGU4KrfuoOz1+ajoELxfj+d8DhrzXDdRJMYO2j2j 2jWkJQzw8bz2DFjqZ73u3rLQt9elaoerO3+7RltAaG5tntxBqvs6UXfhWIphb5D9G0OZVm vq5kV5FGjGz6B1plsTdlpVtOpQAKYVI= X-MC-Unique: wuiEIaB7PZKZVIP56xUwwg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Bin Meng Subject: [PULL 09/20] tests: avoid DOS line endings in PSK file Date: Thu, 27 Oct 2022 18:30:52 +0100 Message-Id: <20221027173103.299479-10-berrange@redhat.com> In-Reply-To: <20221027173103.299479-1-berrange@redhat.com> References: <20221027173103.299479-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666891994263100003 Using FILE * APIs for writing the PSK file results in translation from UNIX to DOS line endings on Windows. When the crypto PSK code later loads the credentials the stray \r will result in failure to load the PSK credentials into GNUTLS. Rather than switching the FILE* APIs to open in binary format, just switch to the more concise g_file_set_contents API. Reviewed-by: Bin Meng Tested-by: Bin Meng Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/unit/crypto-tls-psk-helpers.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/unit/crypto-tls-psk-helpers.c b/tests/unit/crypto-tls-ps= k-helpers.c index 511e08cc9c..c6cc740772 100644 --- a/tests/unit/crypto-tls-psk-helpers.c +++ b/tests/unit/crypto-tls-psk-helpers.c @@ -27,15 +27,14 @@ static void test_tls_psk_init_common(const char *pskfile, const char *user, const char= *key) { - FILE *fp; + g_autoptr(GError) gerr =3D NULL; + g_autofree char *line =3D g_strdup_printf("%s:%s\n", user, key); =20 - fp =3D fopen(pskfile, "w"); - if (fp =3D=3D NULL) { - g_critical("Failed to create pskfile %s: %s", pskfile, strerror(er= rno)); + g_file_set_contents(pskfile, line, strlen(line), &gerr); + if (gerr !=3D NULL) { + g_critical("Failed to create pskfile %s: %s", pskfile, gerr->messa= ge); abort(); } - fprintf(fp, "%s:%s\n", user, key); - fclose(fp); } =20 void test_tls_psk_init(const char *pskfile) --=20 2.37.3