Skip to content

Commit

Permalink
Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/n…
Browse files Browse the repository at this point in the history
…fs-2.6

* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6:
  SUNRPC: Address buffer overrun in rpc_uaddr2sockaddr()
  NFSv4: Fix a cache validation bug which causes getcwd() to return ENOENT
  • Loading branch information
torvalds committed Nov 19, 2009
2 parents 308efab + 1e360a6 commit e6236f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2767,7 +2767,7 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
.pages = &page,
.pgbase = 0,
.count = count,
.bitmask = NFS_SERVER(dentry->d_inode)->cache_consistency_bitmask,
.bitmask = NFS_SERVER(dentry->d_inode)->attr_bitmask,
};
struct nfs4_readdir_res res;
struct rpc_message msg = {
Expand Down
18 changes: 8 additions & 10 deletions net/sunrpc/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,24 +306,25 @@ EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr);
* @sap: buffer into which to plant socket address
* @salen: size of buffer
*
* @uaddr does not have to be '\0'-terminated, but strict_strtoul() and
* rpc_pton() require proper string termination to be successful.
*
* Returns the size of the socket address if successful; otherwise
* zero is returned.
*/
size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len,
struct sockaddr *sap, const size_t salen)
{
char *c, buf[RPCBIND_MAXUADDRLEN];
char *c, buf[RPCBIND_MAXUADDRLEN + sizeof('\0')];
unsigned long portlo, porthi;
unsigned short port;

if (uaddr_len > sizeof(buf))
if (uaddr_len > RPCBIND_MAXUADDRLEN)
return 0;

memcpy(buf, uaddr, uaddr_len);

buf[uaddr_len] = '\n';
buf[uaddr_len + 1] = '\0';

buf[uaddr_len] = '\0';
c = strrchr(buf, '.');
if (unlikely(c == NULL))
return 0;
Expand All @@ -332,9 +333,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len,
if (unlikely(portlo > 255))
return 0;

c[0] = '\n';
c[1] = '\0';

*c = '\0';
c = strrchr(buf, '.');
if (unlikely(c == NULL))
return 0;
Expand All @@ -345,8 +344,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len,

port = (unsigned short)((porthi << 8) | portlo);

c[0] = '\0';

*c = '\0';
if (rpc_pton(buf, strlen(buf), sap, salen) == 0)
return 0;

Expand Down

0 comments on commit e6236f7

Please sign in to comment.