sys/un.h needs strlen in order to define SUN_LEN, but does not need
any of the other things declared by string.h; the path of least
resistance is to prototype strlen locally.
Also, the construct being used to get the size of everything up to the
sun_path member contains a formal dereference of a null pointer and
therefore has undefined behavior. Replace with __SOCKADDR_COMMON_SIZE.
Some old RPC code was relying on sys/un.h to provide all of string.h.
* sys/un.h [__USE_MISC]: Don’t include string.h.
Include bits/types/size_t.h. Prototype strlen locally.
Use __SOCKADDR_COMMON_SIZE for size of leading members of
struct sockaddr_un.
* nis/nis_domain_of.c, nis/yp_xdr.c, sunrpc/svc.c:
Include string.h.
* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.
<https://www.gnu.org/licenses/>. */
#include <rpcsvc/nis.h>
+#include <string.h>
#include <shlib-compat.h>
nis_name
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+#include <string.h>
#include <shlib-compat.h>
/* The NIS v2 protocol suggests 1024 bytes as a maximum length of all fields.
"sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
- "sys/un.h": [ "string.h" ],
# POSIX networking headers
# allowed: netdb.h -> netinet/in.h
#ifdef __USE_MISC
-# include <string.h> /* For prototype of `strlen'. */
+#include <bits/types/size_t.h>
+
+extern size_t strlen (const char *__s)
+ __THROW __attribute_pure__ __nonnull ((1));
/* Evaluate to actual length of the `sockaddr_un' structure. */
-# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
- + strlen ((ptr)->sun_path))
+# define SUN_LEN(ptr) (__SOCKADDR_COMMON_SIZE + strlen ((ptr)->sun_path))
#endif
__END_DECLS
*/
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/svc.h>