summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog8
-rw-r--r--lib/sockopt.c2
-rw-r--r--lib/zebra.h17
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index d50b8590..2fee4611 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,11 @@
+2005-01-04 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * zebra.h: Define ZCMSG_FIRSTHDR appropriately based on whether
+ config.h indicates HAVE_BROKEN_CMSG_FIRSTHDR (as determined
+ by the configure test program).
+ * sockopt.c: (getsockopt_cmsg_data) Use ZCMSG_FIRSTHDR instead
+ of CMSG_FIRSTHDR.
+
2005-01-02 Hasso Tepper <hasso at quagga.net>
* command.c: Revert int -> unsigned int fixes in
diff --git a/lib/sockopt.c b/lib/sockopt.c
index d755746a..81db88d9 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -42,7 +42,7 @@ getsockopt_cmsg_data (struct msghdr *msgh, int level, int type)
struct cmsghdr *cmsg;
void *ptr = NULL;
- for (cmsg = CMSG_FIRSTHDR(msgh);
+ for (cmsg = ZCMSG_FIRSTHDR(msgh);
cmsg != NULL;
cmsg = CMSG_NXTHDR(msgh, cmsg))
if (cmsg->cmsg_level == level && cmsg->cmsg_type)
diff --git a/lib/zebra.h b/lib/zebra.h
index 83da37c5..8c2dcaba 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -215,6 +215,23 @@ typedef int socklen_t;
#endif /* BSDI_NRL */
+#ifdef HAVE_BROKEN_CMSG_FIRSTHDR
+/* This bug is present in Solaris 8 and pre-patch Solaris 9 <sys/socket.h>;
+ please refer to http://bugzilla.quagga.net/show_bug.cgi?id=142 */
+
+/* Check that msg_controllen is large enough. */
+#define ZCMSG_FIRSTHDR(mhdr) \
+ (((size_t)((mhdr)->msg_controllen) >= sizeof(struct cmsghdr)) ? \
+ CMSG_FIRSTHDR(mhdr) : (struct cmsghdr *)NULL)
+
+#warning "CMSG_FIRSTHDR is broken on this platform, using a workaround"
+
+#else /* HAVE_BROKEN_CMSG_FIRSTHDR */
+#define ZCMSG_FIRSTHDR(M) CMSG_FIRSTHDR(M)
+#endif /* HAVE_BROKEN_CMSG_FIRSTHDR */
+
+
+
/*
* RFC 3542 defines several macros for using struct cmsghdr.
* Here, we define those that are not present