DHCPv6: send_packet6: Invalid argument
Shane Kerr
Shane_Kerr at isc.org
Thu Aug 2 10:20:31 UTC 2007
Shane Kerr wrote:
>
> Can you try the attached patch and see if it fixes the problem?
Hm... forgot our list software doesn't like attachments. :(
Here it is inline.
--- common/socket.c.old 2007-07-13 08:43:41.000000000 +0200
+++ common/socket.c 2007-08-02 12:01:15.000000000 +0200
@@ -435,10 +435,18 @@
struct iovec v;
int result;
struct in6_pktinfo *pktinfo;
- char pbuf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+ char *pbuf;
struct cmsghdr *cmsg;
/*
+ * Allocate some suitably-aligned memory.
+ */
+ pbuf = malloc(CMSG_SPACE(sizeof(struct in6_pktinfo)));
+ if (pbuf == NULL) {
+ log_fatal("send_packet6: out of memory");
+ }
+
+ /*
* Initialize our message header structure.
*/
memset(&m, 0, sizeof(m));
@@ -482,6 +490,9 @@
if (result < 0) {
log_error("send_packet6: %m");
}
+
+ free(pbuf);
+
return result;
}
#endif /* DHCPv6 */
@@ -528,13 +539,21 @@
struct sockaddr_in6 *from, struct in6_addr *to_addr) {
struct msghdr m;
struct iovec v;
- char pbuf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+ char *pbuf;
int result;
struct cmsghdr *cmsg;
struct in6_pktinfo *pktinfo;
int found_to_addr;
/*
+ * Allocate some suitably-aligned memory.
+ */
+ pbuf = malloc(CMSG_SPACE(sizeof(struct in6_pktinfo)));
+ if (pbuf == NULL) {
+ log_fatal("receive_packet6: out of memory");
+ }
+
+ /*
* Initialize our message header structure.
*/
memset(&m, 0, sizeof(m));
@@ -594,6 +613,8 @@
}
}
+ free(pbuf);
+
return result;
}
#endif /* DHCPv6 */
More information about the dhcp-users
mailing list