From patchwork Mon Jan 13 22:20:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 11331135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E177139A for ; Tue, 14 Jan 2020 00:40:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 136B0207FD for ; Tue, 14 Jan 2020 00:40:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=crudebyte.com header.i=@crudebyte.com header.b="UQFid1OV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 136B0207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irAFe-0007ie-RA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 Jan 2020 19:40:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35185) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <8d86288c6b169461812b2c5838c35df51396d5ff@lizzy.crudebyte.com>) id 1irAES-0006mo-84 for qemu-devel@nongnu.org; Mon, 13 Jan 2020 19:38:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <8d86288c6b169461812b2c5838c35df51396d5ff@lizzy.crudebyte.com>) id 1irAEQ-0003lN-WC for qemu-devel@nongnu.org; Mon, 13 Jan 2020 19:38:56 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:53853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <8d86288c6b169461812b2c5838c35df51396d5ff@lizzy.crudebyte.com>) id 1irAEQ-0002iH-PL for qemu-devel@nongnu.org; Mon, 13 Jan 2020 19:38:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=ueZKXtIfpbKoSzdo2zVCHwkMKgcaOQPLVmaUXXmHksI=; b=UQFid 1OVALJC5mm/sFuVDn3sDHFBZHf3PfpFYZDZLoTeCgM693wS3Q0CWIl4QHt/XEnSgAKLpGnWKdJfcI NvTRO27/5b3KoyQAQgYdzA/Z7Rpra+FghakP+bzwWJB+cHoeSS2FfofsIVprHGQwTSpj9B3KTg5Gm 4GfkM1K/PYTYd9rdnNenSYmOYhLxmJp6feMfHT6LR64tzJqKV8nky6VTM5HeFWx9OPaCB6wKthhiH IDw116umci3imzJdFqd9TiSlSQcpEkgtYAWlev3NTzZ6KBvo1FfMg/XGXmsQFk9b5dE2bsQR2hm1B dJhaQqo5PCWY1rkuQKaesvL8T0OTQ==; Message-Id: <8d86288c6b169461812b2c5838c35df51396d5ff.1578957500.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 13 Jan 2020 23:20:37 +0100 Subject: [PATCH v3 01/11] tests/virtio-9p: add terminating null in v9fs_string_read() To: qemu-devel@nongnu.org Cc: Greg Kurz X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 91.194.90.13 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The 9p protocol sends strings in general without null termination over the wire. However for future use of this functions it is beneficial for the delivered string to be null terminated though for being able to use the string with standard C functions which often rely on strings being null terminated. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/virtio-9p-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index e7b58e3a0c..06263edb53 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -130,8 +130,9 @@ static void v9fs_string_read(P9Req *req, uint16_t *len, char **string) *len = local_len; } if (string) { - *string = g_malloc(local_len); + *string = g_malloc(local_len + 1); v9fs_memread(req, *string, local_len); + (*string)[local_len] = 0; } else { v9fs_memskip(req, local_len); }