1 // SPDX-License-Identifier: BSD-3-Clause
3 * linux/net/sunrpc/auth_gss/auth_gss_internal.h
5 * Internal definitions for RPCSEC_GSS client authentication
7 * Copyright (c) 2000 The Regents of the University of Michigan.
11 #include <linux/err.h>
12 #include <linux/string.h>
13 #include <linux/sunrpc/xdr.h>
15 static inline const void *
16 simple_get_bytes(const void *p, const void *end, void *res, size_t len)
18 const void *q = (const void *)((const char *)p + len);
19 if (unlikely(q > end || q < p))
20 return ERR_PTR(-EFAULT);
25 static inline const void *
26 simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest)
31 p = simple_get_bytes(p, end, &len, sizeof(len));
34 q = (const void *)((const char *)p + len);
35 if (unlikely(q > end || q < p))
36 return ERR_PTR(-EFAULT);
38 dest->data = kmemdup(p, len, GFP_KERNEL);
39 if (unlikely(dest->data == NULL))
40 return ERR_PTR(-ENOMEM);