Browse Source

Ensure that struct sockaddr is long enough...

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
8ffbbebf11
2 changed files with 12 additions and 4 deletions
  1. 10
    0
      src/include/gpxe/socket.h
  2. 2
    4
      src/include/gpxe/tcpip.h

+ 10
- 0
src/include/gpxe/socket.h View File

14
 /** A socket address family */
14
 /** A socket address family */
15
 typedef uint16_t sa_family_t;
15
 typedef uint16_t sa_family_t;
16
 
16
 
17
+/** Length of a @c struct @c sockaddr */
18
+#define SA_LEN 32
19
+
17
 /**
20
 /**
18
  * Generalized socket address structure
21
  * Generalized socket address structure
19
  *
22
  *
26
 	 * This is an AF_XXX constant.
29
 	 * This is an AF_XXX constant.
27
 	 */
30
 	 */
28
         sa_family_t sa_family;
31
         sa_family_t sa_family;
32
+	/** Padding
33
+	 *
34
+	 * This ensures that a struct @c sockaddr_tcpip is large
35
+	 * enough to hold a socket address for any TCP/IP address
36
+	 * family.
37
+	 */
38
+	char pad[ SA_LEN - sizeof ( sa_family_t ) ];
29
 };
39
 };
30
 
40
 
31
 #endif /* _GPXE_SOCKET_H */
41
 #endif /* _GPXE_SOCKET_H */

+ 2
- 4
src/include/gpxe/tcpip.h View File

21
  */
21
  */
22
 #define TCPIP_EMPTY_CSUM 0xffff
22
 #define TCPIP_EMPTY_CSUM 0xffff
23
 
23
 
24
-/** Length of a @c struct @c sockaddr_tcpip */
25
-#define SA_TCPIP_LEN 32
26
-
27
 /**
24
 /**
28
  * TCP/IP socket address
25
  * TCP/IP socket address
29
  *
26
  *
41
 	 * enough to hold a socket address for any TCP/IP address
38
 	 * enough to hold a socket address for any TCP/IP address
42
 	 * family.
39
 	 * family.
43
 	 */
40
 	 */
44
-	char pad[SA_TCPIP_LEN - sizeof ( sa_family_t ) - sizeof ( uint16_t )];
41
+	char pad[ sizeof ( struct sockaddr ) -
42
+		  ( sizeof ( sa_family_t ) + sizeof ( uint16_t ) ) ];
45
 };
43
 };
46
 
44
 
47
 /** 
45
 /** 

Loading…
Cancel
Save