From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755813AbcCBBnb (ORCPT ); Tue, 1 Mar 2016 20:43:31 -0500 Received: from mail333.us4.mandrillapp.com ([205.201.137.77]:44579 "EHLO mail333.us4.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755115AbcCAXyG (ORCPT ); Tue, 1 Mar 2016 18:54:06 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=K1SegdVL3aKN8Vdm9cpxuikoZM1/FsY+TsMH5gZ96bepsVlFap/mPTn1EdLdKBOxlZNXEJ+KaOTG Bk6FBiLJVsQb2/b4O4cgfFHl1lwIsA9EgMGBEtnLdP3+ChKd8R4Y/olc29cwJfgOqvmYLQzJPy9i Kc3ze4UvF6+f354Jtfw=; From: Greg Kroah-Hartman Subject: [PATCH 3.14 126/130] sunrpc/cache: fix off-by-one in qword_get() X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , Stefan Hajnoczi , "J. Bruce Fields" Message-Id: <20160301234504.217968540@linuxfoundation.org> In-Reply-To: <20160301234459.768886030@linuxfoundation.org> References: <20160301234459.768886030@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.0dc6620cd76c4646a2be52271ee75941 X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:53:40 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Hajnoczi commit b7052cd7bcf3c1478796e93e3dff2b44c9e82943 upstream. The qword_get() function NUL-terminates its output buffer. If the input string is in hex format \xXXXX... and the same length as the output buffer, there is an off-by-one: int qword_get(char **bpp, char *dest, int bufsize) { ... while (len < bufsize) { ... *dest++ = (h << 4) | l; len++; } ... *dest = '\0'; return len; } This patch ensures the NUL terminator doesn't fall outside the output buffer. Signed-off-by: Stefan Hajnoczi Signed-off-by: J. Bruce Fields Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1230,7 +1230,7 @@ int qword_get(char **bpp, char *dest, in if (bp[0] == '\\' && bp[1] == 'x') { /* HEX STRING */ bp += 2; - while (len < bufsize) { + while (len < bufsize - 1) { int h, l; h = hex_to_bin(bp[0]);