• Stefan Hajnoczi's avatar
    sunrpc/cache: fix off-by-one in qword_get() · b7052cd7
    Stefan Hajnoczi authored
    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: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
    b7052cd7
cache.c 44.3 KB