public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] Don’t include string.h from sys/un.h.
@ 2019-06-26 15:50 Zack Weinberg
0 siblings, 0 replies; 3+ messages in thread
From: Zack Weinberg @ 2019-06-26 15:50 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3411 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d4c5ad0509da9bca8eb2d5f65d6367fa65db4465
commit d4c5ad0509da9bca8eb2d5f65d6367fa65db4465
Author: Zack Weinberg <zackw@panix.com>
Date: Wed May 22 12:03:57 2019 -0400
Donât include string.h from sys/un.h.
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.
Diff:
---
nis/nis_domain_of.c | 1 +
nis/yp_xdr.c | 1 +
scripts/check-obsolete-constructs.py | 1 -
socket/sys/un.h | 8 +++++---
sunrpc/svc.c | 1 +
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/nis/nis_domain_of.c b/nis/nis_domain_of.c
index 44c5b04..da26df3 100644
--- a/nis/nis_domain_of.c
+++ b/nis/nis_domain_of.c
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <rpcsvc/nis.h>
+#include <string.h>
#include <shlib-compat.h>
nis_name
diff --git a/nis/yp_xdr.c b/nis/yp_xdr.c
index 3b57673..4c9f1d2 100644
--- a/nis/yp_xdr.c
+++ b/nis/yp_xdr.c
@@ -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.
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index bca0f12..d230fcf 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -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
diff --git a/socket/sys/un.h b/socket/sys/un.h
index 8c7433a..540560e 100644
--- a/socket/sys/un.h
+++ b/socket/sys/un.h
@@ -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
diff --git a/sunrpc/svc.c b/sunrpc/svc.c
index 95ecfbb..8042019 100644
--- a/sunrpc/svc.c
+++ b/sunrpc/svc.c
@@ -53,6 +53,7 @@
*/
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/svc.h>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include string.h from sys/un.h.
@ 2020-01-08 19:20 Zack Weinberg
0 siblings, 0 replies; 3+ messages in thread
From: Zack Weinberg @ 2020-01-08 19:20 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3413 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=225a0f4ef94a6505f2bb28d44d85bb3a9a45e5ef
commit 225a0f4ef94a6505f2bb28d44d85bb3a9a45e5ef
Author: Zack Weinberg <zackw@panix.com>
Date: Wed May 22 12:03:57 2019 -0400
Donât include string.h from sys/un.h.
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.
Diff:
---
nis/nis_domain_of.c | 1 +
nis/yp_xdr.c | 1 +
scripts/check-obsolete-constructs.py | 1 -
socket/sys/un.h | 8 +++++---
sunrpc/svc.c | 1 +
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/nis/nis_domain_of.c b/nis/nis_domain_of.c
index 06b2c54..e8f7140 100644
--- a/nis/nis_domain_of.c
+++ b/nis/nis_domain_of.c
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <rpcsvc/nis.h>
+#include <string.h>
#include <shlib-compat.h>
nis_name
diff --git a/nis/yp_xdr.c b/nis/yp_xdr.c
index 3b57673..4c9f1d2 100644
--- a/nis/yp_xdr.c
+++ b/nis/yp_xdr.c
@@ -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.
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 48a21cd..9008892d 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -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
diff --git a/socket/sys/un.h b/socket/sys/un.h
index 8bc9c3a..d174e37 100644
--- a/socket/sys/un.h
+++ b/socket/sys/un.h
@@ -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
diff --git a/sunrpc/svc.c b/sunrpc/svc.c
index 1aa1109..5c0d4dc 100644
--- a/sunrpc/svc.c
+++ b/sunrpc/svc.c
@@ -53,6 +53,7 @@
*/
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/svc.h>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include string.h from sys/un.h.
@ 2019-06-20 16:06 Zack Weinberg
0 siblings, 0 replies; 3+ messages in thread
From: Zack Weinberg @ 2019-06-20 16:06 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 3411 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fd0a2720650fa560321a7277500b316aec2df503
commit fd0a2720650fa560321a7277500b316aec2df503
Author: Zack Weinberg <zackw@panix.com>
Date: Wed May 22 12:03:57 2019 -0400
Donât include string.h from sys/un.h.
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.
Diff:
---
nis/nis_domain_of.c | 1 +
nis/yp_xdr.c | 1 +
scripts/check-obsolete-constructs.py | 1 -
socket/sys/un.h | 8 +++++---
sunrpc/svc.c | 1 +
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/nis/nis_domain_of.c b/nis/nis_domain_of.c
index 44c5b04..da26df3 100644
--- a/nis/nis_domain_of.c
+++ b/nis/nis_domain_of.c
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include <rpcsvc/nis.h>
+#include <string.h>
#include <shlib-compat.h>
nis_name
diff --git a/nis/yp_xdr.c b/nis/yp_xdr.c
index 3b57673..4c9f1d2 100644
--- a/nis/yp_xdr.c
+++ b/nis/yp_xdr.c
@@ -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.
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index bca0f12..d230fcf 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -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
diff --git a/socket/sys/un.h b/socket/sys/un.h
index 8c7433a..540560e 100644
--- a/socket/sys/un.h
+++ b/socket/sys/un.h
@@ -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
diff --git a/sunrpc/svc.c b/sunrpc/svc.c
index 95ecfbb..8042019 100644
--- a/sunrpc/svc.c
+++ b/sunrpc/svc.c
@@ -53,6 +53,7 @@
*/
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/svc.h>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-08 19:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 15:50 [glibc/zack/no-nested-includes] Don’t include string.h from sys/un.h Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2020-01-08 19:20 Zack Weinberg
2019-06-20 16:06 Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).