From nobody Sun Oct 5 17:23:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525189763469995.5970441506126; Tue, 1 May 2018 08:49:23 -0700 (PDT) Received: from localhost ([::1]:43941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDXWs-0004FD-38 for importer@patchew.org; Tue, 01 May 2018 11:49:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDXV0-0003LB-CP for qemu-devel@nongnu.org; Tue, 01 May 2018 11:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDXUz-0001UX-Ae for qemu-devel@nongnu.org; Tue, 01 May 2018 11:47:26 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54474 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fDXUt-0001Oq-3X; Tue, 01 May 2018 11:47:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFB3C406C78C; Tue, 1 May 2018 15:47:04 +0000 (UTC) Received: from red.redhat.com (ovpn-123-248.rdu2.redhat.com [10.10.123.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D333215CDA7; Tue, 1 May 2018 15:46:59 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 1 May 2018 10:46:53 -0500 Message-Id: <20180501154654.943782-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 01 May 2018 15:47:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 01 May 2018 15:47:05 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] nbd/client: Fix error messages during NBD_INFO_BLOCK_SIZE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , vsementsov@virtuozzo.com, qemu-stable@nongnu.org, "open list:Network Block Dev..." Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A missing space makes for poor error messages. Also, we missed diagnosing a server that sends a maximum block size less than the minimum. Fixes: 081dd1fe CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- nbd/client.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index 7f35b5c3232..7b3caa90ec2 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -436,7 +436,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char *want= name, be32_to_cpus(&info->min_block); if (!is_power_of_2(info->min_block)) { error_setg(errp, "server minimum block size %" PRId32 - "is not a power of two", info->min_block); + " is not a power of two", info->min_block); nbd_send_opt_abort(ioc); return -1; } @@ -451,7 +451,7 @@ static int nbd_opt_go(QIOChannel *ioc, const char *want= name, if (!is_power_of_2(info->opt_block) || info->opt_block < info->min_block) { error_setg(errp, "server preferred block size %" PRId32 - "is not valid", info->opt_block); + " is not valid", info->opt_block); nbd_send_opt_abort(ioc); return -1; } @@ -462,6 +462,12 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wan= tname, return -1; } be32_to_cpus(&info->max_block); + if (info->max_block < info->min_block) { + error_setg(errp, "server maximum block size %" PRId32 + " is not valid", info->max_block); + nbd_send_opt_abort(ioc); + return -1; + } trace_nbd_opt_go_info_block_size(info->min_block, info->opt_bl= ock, info->max_block); break; --=20 2.14.3