]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Don’t include string.h from sys/un.h.
authorZack Weinberg <zackw@panix.com>
Wed, 22 May 2019 16:03:57 +0000 (12:03 -0400)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 18:45:45 +0000 (13:45 -0500)
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.

nis/nis_domain_of.c
nis/yp_xdr.c
scripts/check-obsolete-constructs.py
socket/sys/un.h
sunrpc/svc.c

index 06b2c54aeb329c53b4824565e84faf7f6a41d8c4..e8f714069a00caa71eb24f5acf8a3ddc22577ad7 100644 (file)
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <rpcsvc/nis.h>
+#include <string.h>
 #include <shlib-compat.h>
 
 nis_name
index 3b576731da247966a43144f741602b134dc821d3..4c9f1d22a023afd2002f732e0c87e93466d76f5d 100644 (file)
@@ -31,6 +31,7 @@
 
 #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.
index 48a21cde0f913aa7ff50ffd2974d2ee0d98b71b6..9008892dafcde09e1a9ac70766036ea321e52274 100755 (executable)
@@ -539,7 +539,6 @@ HEADER_ALLOWED_INCLUDES = {
     "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
index 8bc9c3adb88aaf22cc1871e90bae185f4944c351..d174e37ea663829c297b07b1355e3abdfa653918 100644 (file)
@@ -34,11 +34,13 @@ struct sockaddr_un
 
 
 #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
index 1aa11094bf47d72d211c563f45f5ffdfcd7477ba..5c0d4dcaebcc0bec9ba40237aa18f6e8894adfdb 100644 (file)
@@ -53,6 +53,7 @@
  */
 
 #include <errno.h>
+#include <string.h>
 #include <unistd.h>
 #include <rpc/rpc.h>
 #include <rpc/svc.h>