Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1350000 > unrolled thread

[PATCH 3.12 110/116] sunrpc/cache: fix off-by-one in qword_get()

Started byJiri Slaby <jslaby@suse.cz>
First post2016-03-04 10:20 +0100
Last post2016-03-04 10:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3.12 110/116] sunrpc/cache: fix off-by-one in qword_get() Jiri Slaby <jslaby@suse.cz> - 2016-03-04 10:20 +0100

#1350000 — [PATCH 3.12 110/116] sunrpc/cache: fix off-by-one in qword_get()

FromJiri Slaby <jslaby@suse.cz>
Date2016-03-04 10:20 +0100
Subject[PATCH 3.12 110/116] sunrpc/cache: fix off-by-one in qword_get()
Message-ID<r8U3V-4v0-37@gated-at.bofh.it>
From: Stefan Hajnoczi <stefanha@redhat.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

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 <stefanha@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 net/sunrpc/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 8a6e3b0d25d4..f3e2b7d8f325 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1232,7 +1232,7 @@ int qword_get(char **bpp, char *dest, int bufsize)
 	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]);
-- 
2.7.2

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web