From patchwork Mon Jan 20 22:29:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 11343005 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 3DDFE6C1 for ; Tue, 21 Jan 2020 01:42:59 +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 14E9922522 for ; Tue, 21 Jan 2020 01:42:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=crudebyte.com header.i=@crudebyte.com header.b="Mc2tuL/5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14E9922522 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]:46868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itiZG-0006yW-4V for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jan 2020 20:42:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44617) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <52c84e2ce3bcafc2a38eed13b8c8e23bc1a8ecb9@lizzy.crudebyte.com>) id 1itiYU-00066s-Kr for qemu-devel@nongnu.org; Mon, 20 Jan 2020 20:42:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <52c84e2ce3bcafc2a38eed13b8c8e23bc1a8ecb9@lizzy.crudebyte.com>) id 1itiYT-0005X9-DX for qemu-devel@nongnu.org; Mon, 20 Jan 2020 20:42:10 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:51609) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <52c84e2ce3bcafc2a38eed13b8c8e23bc1a8ecb9@lizzy.crudebyte.com>) id 1itiYT-00053N-74 for qemu-devel@nongnu.org; Mon, 20 Jan 2020 20:42:09 -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=WTaGxFXa1SCFsUf5hlI8KVFd7uagnyrYBvr3WyqZULo=; b=Mc2tu L/5gWnM6RQa/5xNTro2elWT+Ja/m2hAcssLxtsNhybRFnZSLdZ+An/8iqZld5mMMB2IR49HeVlqnJ qnYXvGrqeND1CZvCEj891/OLGDYi1u7xsOUMnknZBLD2MVT4zHq0uxfnEzGPmHOkcujji39zu3gtN ZgQxRR5ClVG9JVwY7F2gf6pKTi4TvZCkEM8wzELsJQWYI6VH4MY4HS4uYH0a5RNMLeZVy5M9Dylr5 BSFCBUdgj/F4f5MyWVKpfpVXJ4eYKBe+hG0siVEBrYdRIlzs09BOZa577oqcT0DVjh93Xb9cCt9Y3 lricHjwf4MeNrW4kZhgVyYChgXA0Q==; Message-Id: <52c84e2ce3bcafc2a38eed13b8c8e23bc1a8ecb9.1579567019.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 20 Jan 2020 23:29:36 +0100 Subject: [PATCH v4 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/qtest/virtio-9p-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index e7b58e3a0c..06263edb53 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/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); }