summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
Diffstat (limited to 'librpc')
-rw-r--r--librpc/ndr/libndr.h1
-rw-r--r--librpc/ndr/ndr_basic.c15
2 files changed, 12 insertions, 4 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 93d95cf398..c110b76ae5 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -189,6 +189,7 @@ enum ndr_err_code {
NDR_ERR_RANGE,
NDR_ERR_TOKEN,
NDR_ERR_IPV4ADDRESS,
+ NDR_ERR_IPV6ADDRESS,
NDR_ERR_INVALID_POINTER,
NDR_ERR_UNREAD_BYTES,
NDR_ERR_NDR64
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index aa49898dd0..31a8b9de6d 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -876,14 +876,21 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ipv6address(struct ndr_pull *ndr, int ndr_fl
*/
_PUBLIC_ enum ndr_err_code ndr_push_ipv6address(struct ndr_push *ndr, int ndr_flags, const char *address)
{
- uint32_t addr;
+ uint8_t addr[IPV6_BYTES];
+ int ret;
+
if (!is_ipaddress(address)) {
- return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS,
+ return ndr_push_error(ndr, NDR_ERR_IPV6ADDRESS,
"Invalid IPv6 address: '%s'",
address);
}
- addr = inet_addr(address);
- NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr)));
+ ret = inet_pton(AF_INET6, address, addr);
+ if (ret <= 0) {
+ return NDR_ERR_IPV6ADDRESS;
+ }
+
+ NDR_CHECK(ndr_push_array_uint8(ndr, ndr_flags, addr, IPV6_BYTES));
+
return NDR_ERR_SUCCESS;
}