From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boR2h-0007hD-55 for qemu-devel@nongnu.org; Mon, 26 Sep 2016 04:13:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boR2d-00073u-EK for qemu-devel@nongnu.org; Mon, 26 Sep 2016 04:13:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boR2d-00073g-7z for qemu-devel@nongnu.org; Mon, 26 Sep 2016 04:13:35 -0400 Date: Mon, 26 Sep 2016 09:13:30 +0100 From: "Daniel P. Berrange" Message-ID: <20160926081330.GA18393@redhat.com> Reply-To: "Daniel P. Berrange" References: <1474683000-346560-1-git-send-email-arei.gonglei@huawei.com> <1474683000-346560-4-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1474683000-346560-4-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v2 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei Cc: qemu-devel@nongnu.org, wu.wubin@huawei.com On Sat, Sep 24, 2016 at 10:10:00AM +0800, Gonglei wrote: > Signed-off-by: Gonglei > --- > crypto/cipher-builtin.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c > index fd59a9e..d710608 100644 > --- a/crypto/cipher-builtin.c > +++ b/crypto/cipher-builtin.c > @@ -433,6 +433,16 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, > { > QCryptoCipher *cipher; > > + switch (mode) { > + case QCRYPTO_CIPHER_MODE_ECB: > + case QCRYPTO_CIPHER_MODE_CBC: > + case QCRYPTO_CIPHER_MODE_XTS: Presumably you intended to have 'break' here, otherwise this code rejects everything > + default: > + error_setg(errp, "Unsupported cipher mode %s", > + QCryptoCipherMode_lookup[mode]); > + return NULL; > + } > + > cipher = g_new0(QCryptoCipher, 1); > cipher->alg = alg; > cipher->mode = mode; Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|