From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDx4N-0005nB-Ti for qemu-devel@nongnu.org; Mon, 26 Aug 2013 09:43:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VDx4H-0006lA-V2 for qemu-devel@nongnu.org; Mon, 26 Aug 2013 09:42:59 -0400 Message-ID: <521B5B49.9080001@redhat.com> Date: Mon, 26 Aug 2013 15:42:33 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1377249737-12570-1-git-send-email-aik@ozlabs.ru> <24C2B209-2082-4AF8-A8FB-1FF8A8B7751B@suse.de> <1377468637.3819.27.camel@pasglop> <87vc2tysur.fsf@linux.vnet.ibm.com> <1377497959.3819.36.camel@pasglop> <87li3ozura.fsf@linux.vnet.ibm.com> In-Reply-To: <87li3ozura.fsf@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] spapr-vscsi: Adding VSCSI capabilities List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf , qemu-devel@nongnu.org Il 26/08/2013 11:06, Nikunj A Dadhania ha scritto: >>> + fprintf(stderr, "vscsi_send_capabilities: size out of bound !\n"); >>> + goto error_out; >>> + } >> >> I am not 100% familiar with the protocol, could it be that we should >> just read sizeof(cap) instead of erroring out or is there no way it >> can be correct and have a len too long ? > > If the length is incorrect, can we trust whether cap is correct or is of > the type we are expecting? We shouldn't care, it'd be a guest bug. If the guest is asking for say 1024 bytes, we do not have to fill all of them. It is in principle possible that a subsequent revision of vscsi will make the struct larger; perhaps a bit in the first part of the struct will tell the guest if the second part has been filled. Unless the spec explicitly say the opposite, I would just zero the bytes between sizeof(cap) and len. Paolo