diff options
author | David S. Miller <davem@davemloft.net> | 2009-12-01 23:46:35 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 23:46:35 (GMT) |
commit | 7e8f44f8d4fa9bb35e32c161fbcdbd6b9e6400e3 (patch) | |
tree | cf6d526a070a06b365ab0ceb4e1c3ca9ad94666e /net/sunrpc/addr.c | |
parent | 138f3c8518976953563a1316d7e0420c72d4ab96 (diff) | |
parent | 2127816366e0ffbc1426fa69e7b9b2bebd2e2288 (diff) | |
download | linux-fsl-qoriq-7e8f44f8d4fa9bb35e32c161fbcdbd6b9e6400e3.tar.xz |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'net/sunrpc/addr.c')
-rw-r--r-- | net/sunrpc/addr.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index 22e8fd8..c7450c8 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c @@ -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; @@ -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; @@ -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; |