[{"id":3684004,"web_url":"http://patchwork.ozlabs.org/comment/3684004/","msgid":"<afHrjFrMrxroKArd@fedora>","list_archive_url":null,"date":"2026-04-29T11:29:16","subject":"Re: [PATCH 3/6] tests: Set sizes for arrays of expected TPM\n responses and requests","submitter":{"id":91136,"url":"http://patchwork.ozlabs.org/api/people/91136/","name":"Arun Menon","email":"armenon@redhat.com"},"content":"Hi,\n\nOn Tue, Apr 28, 2026 at 01:07:15PM +0000, Stefan Berger wrote:\n> Set the sizes of byte arrays holding TPM requests and responses to avoid a\n> terminating NUL byte to be added and to only compare the expected part of\n> responses.\n> \n> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>\n> ---\n>  tests/qtest/tpm-tests.c |  4 ++--\n>  tests/qtest/tpm-util.c  | 10 +++++-----\n>  2 files changed, 7 insertions(+), 7 deletions(-)\n> \n> diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c\n> index 197714f8d9..dcbf5457ed 100644\n> --- a/tests/qtest/tpm-tests.c\n> +++ b/tests/qtest/tpm-tests.c\n> @@ -59,7 +59,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,\n>      tpm_util_startup(s, tx);\n>      tpm_util_pcrextend(s, tx);\n>  \n> -    static const unsigned char tpm_pcrread_resp[] =\n> +    static const unsigned char tpm_pcrread_resp[62] =\n>          \"\\x80\\x01\\x00\\x00\\x00\\x3e\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x16\\x00\\x00\"\n>          \"\\x00\\x01\\x00\\x0b\\x03\\x00\\x04\\x00\\x00\\x00\\x00\\x01\\x00\\x20\\xf6\\x85\"\n>          \"\\x98\\xe5\\x86\\x8d\\xe6\\x8b\\x97\\x29\\x99\\x60\\xf2\\x71\\x7d\\x17\\x67\\x89\"\n\nCan we define it as an initializer list instead of a string literal like\nbelow?\n\nstatic const unsigned char tpm_pcrread_resp[] = {0x80, 0x01, 0x00,\n0x00,...};\n\nThis one avoids the null terminator.\n\nstatic const unsigned char tpm_pcrread_resp[] =\n          {0x80,0x01,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00,0x00,0x00,\n           0x00,0x16,0x00,0x00,0x00,0x01,0x00,0x0b,0x03,0x00,0x04,0x00,\n           0x00,0x00,0x00,0x01,0x00,0x20,0xf6,0x85,0x98,0xe5,0x86,0x8d,\n           0xe6,0x8b,0x97,0x29,0x99,0x60,0xf2,0x71,0x7d,0x17,0x67,0x89,\n           0xa4,0x2f,0x9a,0xae,0xa8,0xc7,0xb7,0xaa,0x79,0xa8,0x62,0x56,\n           0xc1,0xde};\n\nstatic const unsigned char tpm_pcrextend[] =\n          {0x80,0x02,0x00,0x00,0x00,0x41,0x00,0x00,0x01,0x82,0x00,0x00,\n           0x00,0x0a,0x00,0x00,0x00,0x09,0x40,0x00,0x00,0x09,0x00,0x00,\n           0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x0b,0x74,0x65,0x73,\n           0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\n           0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\n           0x00,0x00,0x00,0x00,0x00};\n\nstatic const unsigned char tpm_pcrextend_resp[] =\n          {0x80,0x02,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,\n           0x00,0x00,0x00,0x00,0x01,0x00,0x00};\n\nstatic const unsigned char tpm_pcrread[] =\n          {0x80,0x01,0x00,0x00,0x00,0x14,0x00,0x00,0x01,0x7e,0x00,0x00,\n           0x00,0x01,0x00,0x0b,0x03,0x00,0x04,0x00};\n\n> @@ -105,7 +105,7 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path,\n>      tpm_util_startup(src_qemu, tx);\n>      tpm_util_pcrextend(src_qemu, tx);\n>  \n> -    static const unsigned char tpm_pcrread_resp[] =\n> +    static const unsigned char tpm_pcrread_resp[62] =\n>          \"\\x80\\x01\\x00\\x00\\x00\\x3e\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x16\\x00\\x00\"\n>          \"\\x00\\x01\\x00\\x0b\\x03\\x00\\x04\\x00\\x00\\x00\\x00\\x01\\x00\\x20\\xf6\\x85\"\n>          \"\\x98\\xe5\\x86\\x8d\\xe6\\x8b\\x97\\x29\\x99\\x60\\xf2\\x71\\x7d\\x17\\x67\\x89\"\n> diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c\n> index 2cb2dd4796..1a47099807 100644\n> --- a/tests/qtest/tpm-util.c\n> +++ b/tests/qtest/tpm-util.c\n> @@ -54,9 +54,9 @@ void tpm_util_crb_transfer(QTestState *s,\n>  void tpm_util_startup(QTestState *s, tx_func *tx)\n>  {\n>      unsigned char buffer[1024];\n> -    static const unsigned char tpm_startup[] =\n> +    static const unsigned char tpm_startup[12] =\n>          \"\\x80\\x01\\x00\\x00\\x00\\x0c\\x00\\x00\\x01\\x44\\x00\\x00\";\n> -    static const unsigned char tpm_startup_resp[] =\n> +    static const unsigned char tpm_startup_resp[10] =\n>          \"\\x80\\x01\\x00\\x00\\x00\\x0a\\x00\\x00\\x00\\x00\";\n>  \n>      tx(s, tpm_startup, sizeof(tpm_startup), buffer, sizeof(buffer));\n> @@ -68,14 +68,14 @@ void tpm_util_startup(QTestState *s, tx_func *tx)\n>  void tpm_util_pcrextend(QTestState *s, tx_func *tx)\n>  {\n>      unsigned char buffer[1024];\n> -    static const unsigned char tpm_pcrextend[] =\n> +    static const unsigned char tpm_pcrextend[65] =\n>          \"\\x80\\x02\\x00\\x00\\x00\\x41\\x00\\x00\\x01\\x82\\x00\\x00\\x00\\x0a\\x00\\x00\"\n>          \"\\x00\\x09\\x40\\x00\\x00\\x09\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\"\n>          \"\\x0b\\x74\\x65\\x73\\x74\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n>          \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n>          \"\\x00\";\n>  \n> -    static const unsigned char tpm_pcrextend_resp[] =\n> +    static const unsigned char tpm_pcrextend_resp[19] =\n>          \"\\x80\\x02\\x00\\x00\\x00\\x13\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n>          \"\\x01\\x00\\x00\";\n>  \n> @@ -89,7 +89,7 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx,\n>                        const unsigned char *exp_resp, size_t exp_resp_size)\n>  {\n>      unsigned char buffer[1024];\n> -    static const unsigned char tpm_pcrread[] =\n> +    static const unsigned char tpm_pcrread[20] =\n>          \"\\x80\\x01\\x00\\x00\\x00\\x14\\x00\\x00\\x01\\x7e\\x00\\x00\\x00\\x01\\x00\\x0b\"\n>          \"\\x03\\x00\\x04\\x00\";\n>  \n> -- \n> 2.43.0\n> \n\nRegards,\nArun Menon","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Dhe/GHFG;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=cRl/IyLr;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5FTB1dttz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 21:29:50 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wI36i-0002gR-7R; Wed, 29 Apr 2026 07:29:32 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <armenon@redhat.com>)\n id 1wI36g-0002gC-Af\n for qemu-devel@nongnu.org; Wed, 29 Apr 2026 07:29:30 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <armenon@redhat.com>)\n id 1wI36d-0007jn-9A\n for qemu-devel@nongnu.org; Wed, 29 Apr 2026 07:29:29 -0400","from mail-pl1-f197.google.com (mail-pl1-f197.google.com\n [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-361-YCwmO2h1P9OGIUtZ9-I18g-1; Wed, 29 Apr 2026 07:29:23 -0400","by mail-pl1-f197.google.com with SMTP id\n d9443c01a7336-2b7aba0af02so61812735ad.2\n for <qemu-devel@nongnu.org>; Wed, 29 Apr 2026 04:29:23 -0700 (PDT)","from fedora ([49.36.106.198]) by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b98895ca58sm20188935ad.60.2026.04.29.04.29.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 29 Apr 2026 04:29:21 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777462164;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n in-reply-to:in-reply-to:references:references;\n bh=F1G3qtObFZN0IpL3ksnpNH1qBy8V3S0xlMXbqRQ0D10=;\n b=Dhe/GHFGcy3ttbKF1eueCOX23wasmaGSjcWLgl41Xxiaz13r3aZoAoO1t37L1ECn+9LnxX\n H6JR3v6ADP9RVgxfovWY8Bypn9O9R+xJa9s/T3/Xz3DZ3rYVUSvDbBOwBmGn1c5FzOceaO\n XdeZ+mqknMyWzOLlAv4KklmLyd2qu0E=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1777462162; x=1778066962; darn=nongnu.org;\n h=in-reply-to:content-disposition:mime-version:references:message-id\n :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to;\n bh=F1G3qtObFZN0IpL3ksnpNH1qBy8V3S0xlMXbqRQ0D10=;\n b=cRl/IyLrCZ79IJBvzC22JDZeTW/UV6nVUAKgh+Jtnvi1JwmpaD++QuVRWvCddIsSLX\n ZHpKdDWPWNgPv7tnr72UzVsO6KYZPhhUQbgf82MjojoM5a5+gx/JV0Wz5BkL6BxTgx9W\n mjOBCILH2w6KVEr3QXLxO3zD7SHQcADGAjYgOuMW67WDeBkky57oj3Mj8sIvxiSeHgVh\n tQPEFqkgifz/pxqFqMBXW7lpqDgo4uaIVR2zb5sD+aUrxWVjXweAU21Jd/VeYNk5UDDg\n WjlnXhgkUFLB2y/upGAg5lVGDEf2xksoMvNaF3nFJD60zFtGYCVSfaSkSddcnyIa5hXo\n Gt/Q=="],"X-MC-Unique":"YCwmO2h1P9OGIUtZ9-I18g-1","X-Mimecast-MFC-AGG-ID":"YCwmO2h1P9OGIUtZ9-I18g_1777462162","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777462162; x=1778066962;\n h=in-reply-to:content-disposition:mime-version:references:message-id\n :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=F1G3qtObFZN0IpL3ksnpNH1qBy8V3S0xlMXbqRQ0D10=;\n b=J4WSnO37VcAg/oxj/iCZu7erVvaFQmlFuKAKsgzDxIn9KM4Nbhd3cOIPjoyG/1CrYB\n j6e2ukR5usKXJJPXh0ai75dYTOOBjDkmhsmPsyK/uZ6jmKHyutTZBFokwNUjZQQDKwWD\n OW6Fu4WoZcBuXPl+nyqwsAXLjV3Lf3p8SVKDnnbDWzMLCS9LKFq7tkFAlP8bEL+MtXX+\n m/PWABGRUn6OE4XESFW/CaejSXeOgpeCbpRrrQITTRqggOKirKxQBY/PmJ5jWyzrGam9\n gG0BELci2WRQF1fB9itPrq4kAyR7gObFuhogf6zOGg88XmWBhfjhufK4WN80+h3AczDi\n V21g==","X-Gm-Message-State":"AOJu0YzVzILetok9aePxWhDkaPWGB+LiLg/VLjPGuITzRZqtXmmCy2NH\n qaPOO6U7XQTPHgJq1qTCLrbIjU+QHRvDgdaPR+Q8ChlH7V/BzulCXs1CBtvh9+26p1/Gs4FKRU9\n J+zC2/RERyU8RqDHomJru5NcTxCdj9QnwiOwrFdq4uIcyevh/+TK35YNP","X-Gm-Gg":"AeBDievmWTRgbT2iz7vaQI08g5anIALCCGz4DY3KgS85etYFPskzqYwHTlvLUgBEfNG\n zG9+d+yfntvWgBv74D/HQ7Y0EelZkaRXM3nX6NH/R9gAJ4dyWBdHmZ8sX/WEwkhgqow68vEoiZQ\n NDFSlNF2gU/aSvp04DEWmegxFmC3gZYgW2oJhxc+iqhFtSIEOQmNlc+jPG40sP88ypXXUSf/Qb7\n ov4OYEMIMIj6Fv7egMthAUCaHwvwoCMIGKGCSIl1+YZRppZ0MG1epK3u0zNsdmqnmHbInrWDIfj\n EZKx3ctn1k9/Q1OnR6wmg29138bBG0eFNp3uZyWg7J2m/FIkNMhr2FOSlkvH0nGNPas01LtQYiO\n /kj+Y5SJfsllmIRb1ieJBvYI=","X-Received":["by 2002:a17:902:f244:b0:2b0:b016:773f with SMTP id\n d9443c01a7336-2b987323f6emr23318615ad.11.1777462161979;\n Wed, 29 Apr 2026 04:29:21 -0700 (PDT)","by 2002:a17:902:f244:b0:2b0:b016:773f with SMTP id\n d9443c01a7336-2b987323f6emr23318335ad.11.1777462161321;\n Wed, 29 Apr 2026 04:29:21 -0700 (PDT)"],"Date":"Wed, 29 Apr 2026 16:59:16 +0530","From":"Arun Menon <armenon@redhat.com>","To":"Stefan Berger <stefanb@linux.ibm.com>","Cc":"qemu-devel@nongnu.org, marcandre.lureau@redhat.com","Subject":"Re: [PATCH 3/6] tests: Set sizes for arrays of expected TPM\n responses and requests","Message-ID":"<afHrjFrMrxroKArd@fedora>","References":"<20260428130718.1325177-1-stefanb@linux.ibm.com>\n <20260428130718.1325177-4-stefanb@linux.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260428130718.1325177-4-stefanb@linux.ibm.com>","Received-SPF":"pass client-ip=170.10.129.124; envelope-from=armenon@redhat.com;\n helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_PASS=-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":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"}}]