[Bug 1187301] Re: netinet/in.h address check macros such as IN6_IS_ADDR_V4MAPPED broken in strict conformance mode (gcc -std=c99)
Matthias Andree
1187301 at bugs.launchpad.net
Tue Jun 4 08:53:15 UTC 2013
** Description changed:
The eglibc netinet/in.h macros to deal with IPv6 address classes are
- broken in stricts conformance mode because they access symbols that are
+ broken in strict conformance mode because they access symbols that are
not expose in strict conformance mode.
The macros should be looking at s6_addr, rather than s6_addr32.
Download the attached try.c and then see:
: this is relaxed mode:
$ gcc -c -Wall -Wextra -std=gnu99 /tmp/try.c -o /tmp/try.o
(no console output -> success)
: this is conformance mode (c99 instead of gnu99):
$ LC_ALL=C gcc -c -Wall -Wextra -std=c99 /tmp/try.c -o /tmp/try.o
/tmp/try.c: In function 'f':
/tmp/try.c:5:18: error: 'const struct in6_addr' has no member named 's6_addr32'
/tmp/try.c:5:18: error: 'const struct in6_addr' has no member named 's6_addr32'
/tmp/try.c:5:18: error: 'const struct in6_addr' has no member named 's6_addr32'
Line numbers in try.c are:
- 1 #include <netinet/in.h>
- 2
- 3 int f(void) {
- 4 struct sockaddr_in6 sa;
- 5 int result = IN6_IS_ADDR_V4MAPPED(&sa.sin6_addr);
- 6 return result;
- 7 }
+ 1 #include <netinet/in.h>
+ 2
+ 3 int f(void) {
+ 4 struct sockaddr_in6 sa;
+ 5 int result = IN6_IS_ADDR_V4MAPPED(&sa.sin6_addr);
+ 6 return result;
+ 7 }
POSIX:
- The <netinet/in.h> header shall define the in6_addr structure that contains at
- least the following member:
+ The <netinet/in.h> header shall define the in6_addr structure that contains at
+ least the following member:
- uint8_t s6_addr[16]
+ uint8_t s6_addr[16]
So s6_addr32 is unavailable in strict mode (this is deliberate through
preprocessing inside in.h near line 209):
- 197 /* IPv6 address */
- 198 struct in6_addr
- 199 {
- 200 union
- 201 {
- 202 uint8_t __u6_addr8[16];
- 203 #if defined __USE_MISC || defined __USE_GNU
- 204 uint16_t __u6_addr16[8];
- 205 uint32_t __u6_addr32[4];
- 206 #endif
- 207 } __in6_u;
- 208 #define s6_addr __in6_u.__u6_addr8
- 209 #if defined __USE_MISC || defined __USE_GNU
- 210 # define s6_addr16 __in6_u.__u6_addr16
- 211 # define s6_addr32 __in6_u.__u6_addr32
- 212 #endif
- 213 };
- 214
-
+ 197 /* IPv6 address */
+ 198 struct in6_addr
+ 199 {
+ 200 union
+ 201 {
+ 202 uint8_t __u6_addr8[16];
+ 203 #if defined __USE_MISC || defined __USE_GNU
+ 204 uint16_t __u6_addr16[8];
+ 205 uint32_t __u6_addr32[4];
+ 206 #endif
+ 207 } __in6_u;
+ 208 #define s6_addr __in6_u.__u6_addr8
+ 209 #if defined __USE_MISC || defined __USE_GNU
+ 210 # define s6_addr16 __in6_u.__u6_addr16
+ 211 # define s6_addr32 __in6_u.__u6_addr32
+ 212 #endif
+ 213 };
+ 214
+
Workaround:
- #define _GNU_SOURCE
+ #define _GNU_SOURCE
_before_ the very first #include line in the same compilation unit (.c file)
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libc6-dev 2.15-0ubuntu10.4
ProcVersionSignature: Ubuntu 3.2.0-45.70-generic 3.2.44
Uname: Linux 3.2.0-45-generic x86_64
NonfreeKernelModules: fglrx
ApportVersion: 2.0.1-0ubuntu17.2
Architecture: amd64
Date: Tue Jun 4 10:30:53 2013
MarkForUpload: True
ProcEnviron:
- LANGUAGE=de_DE:en
- TERM=xterm
- PATH=(custom, no user)
- LANG=de_DE.UTF-8
- SHELL=/bin/bash
+ LANGUAGE=de_DE:en
+ TERM=xterm
+ PATH=(custom, no user)
+ LANG=de_DE.UTF-8
+ SHELL=/bin/bash
SourcePackage: eglibc
UpgradeStatus: No upgrade log present (probably fresh install)
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to eglibc in Ubuntu.
https://bugs.launchpad.net/bugs/1187301
Title:
netinet/in.h address check macros such as IN6_IS_ADDR_V4MAPPED broken
in strict conformance mode (gcc -std=c99)
Status in “eglibc” package in Ubuntu:
Confirmed
Bug description:
The eglibc netinet/in.h macros to deal with IPv6 address classes are
broken in strict conformance mode because they access symbols that are
not expose in strict conformance mode.
The macros should be looking at s6_addr, rather than s6_addr32.
Download the attached try.c and then see:
: this is relaxed mode:
$ gcc -c -Wall -Wextra -std=gnu99 /tmp/try.c -o /tmp/try.o
(no console output -> success)
: this is conformance mode (c99 instead of gnu99):
$ LC_ALL=C gcc -c -Wall -Wextra -std=c99 /tmp/try.c -o /tmp/try.o
/tmp/try.c: In function 'f':
/tmp/try.c:5:18: error: 'const struct in6_addr' has no member named 's6_addr32'
/tmp/try.c:5:18: error: 'const struct in6_addr' has no member named 's6_addr32'
/tmp/try.c:5:18: error: 'const struct in6_addr' has no member named 's6_addr32'
Line numbers in try.c are:
1 #include <netinet/in.h>
2
3 int f(void) {
4 struct sockaddr_in6 sa;
5 int result = IN6_IS_ADDR_V4MAPPED(&sa.sin6_addr);
6 return result;
7 }
POSIX:
The <netinet/in.h> header shall define the in6_addr structure that contains at
least the following member:
uint8_t s6_addr[16]
So s6_addr32 is unavailable in strict mode (this is deliberate through
preprocessing inside in.h near line 209):
197 /* IPv6 address */
198 struct in6_addr
199 {
200 union
201 {
202 uint8_t __u6_addr8[16];
203 #if defined __USE_MISC || defined __USE_GNU
204 uint16_t __u6_addr16[8];
205 uint32_t __u6_addr32[4];
206 #endif
207 } __in6_u;
208 #define s6_addr __in6_u.__u6_addr8
209 #if defined __USE_MISC || defined __USE_GNU
210 # define s6_addr16 __in6_u.__u6_addr16
211 # define s6_addr32 __in6_u.__u6_addr32
212 #endif
213 };
214
Workaround:
#define _GNU_SOURCE
_before_ the very first #include line in the same compilation unit (.c file)
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libc6-dev 2.15-0ubuntu10.4
ProcVersionSignature: Ubuntu 3.2.0-45.70-generic 3.2.44
Uname: Linux 3.2.0-45-generic x86_64
NonfreeKernelModules: fglrx
ApportVersion: 2.0.1-0ubuntu17.2
Architecture: amd64
Date: Tue Jun 4 10:30:53 2013
MarkForUpload: True
ProcEnviron:
LANGUAGE=de_DE:en
TERM=xterm
PATH=(custom, no user)
LANG=de_DE.UTF-8
SHELL=/bin/bash
SourcePackage: eglibc
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1187301/+subscriptions
More information about the foundations-bugs
mailing list