Skip to content

Commit

Permalink
SUNRPC: Use correct type in buffer length calculations
Browse files Browse the repository at this point in the history
Use correct type signage in gss_krb5_remove_padding() when doing length
calculations.  Both xdr_buf.len and iov.iov_len are size_t, which is
unsigned; so use an unsigned type for our temporary length variable to
ensure we don't overflow it..

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Oct 9, 2007
1 parent afde94f commit 67f97d8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/sunrpc/auth_gss/gss_krb5_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ gss_krb5_remove_padding(struct xdr_buf *buf, int blocksize)
{
u8 *ptr;
u8 pad;
int len = buf->len;
size_t len = buf->len;

if (len <= buf->head[0].iov_len) {
pad = *(u8 *)(buf->head[0].iov_base + len - 1);
Expand All @@ -53,9 +53,9 @@ gss_krb5_remove_padding(struct xdr_buf *buf, int blocksize)
} else
len -= buf->head[0].iov_len;
if (len <= buf->page_len) {
int last = (buf->page_base + len - 1)
unsigned int last = (buf->page_base + len - 1)
>>PAGE_CACHE_SHIFT;
int offset = (buf->page_base + len - 1)
unsigned int offset = (buf->page_base + len - 1)
& (PAGE_CACHE_SIZE - 1);
ptr = kmap_atomic(buf->pages[last], KM_USER0);
pad = *(ptr + offset);
Expand Down

0 comments on commit 67f97d8

Please sign in to comment.