]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sunrpc/cache: fix off-by-one in qword_get()
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 18 Feb 2016 18:55:54 +0000 (18:55 +0000)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:45:28 +0000 (15:45 -0700)
commita22cd61a29bbcfac02f58def1d588049d599f87e
tree54c0749a6432c7a65166ef86554e81632a7f3c27
parentb42ea39c98e47a5f12824e4328008a4579427185
sunrpc/cache: fix off-by-one in qword_get()

Orabug: 23330967

[ Upstream commit b7052cd7bcf3c1478796e93e3dff2b44c9e82943 ]

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>
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 4ba9f8051f7fc263cc5915fd6c2ac6d9195418b4)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
net/sunrpc/cache.c