-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Description
I was tracing a program in examples/ this evening and noticed that we have a myriad of different max hostname lengths ranging from 20 - 1024, and slight variations in handling gethostname():
https://gist.github.com/kmroz/6fb7699712d41abb4cd2ba9553163c82
I thought it might be a good idea to use, if available, what's in limits.h:HOST_NAME_MAX. Something like:
diff --git a/opal/include/opal_config_bottom.h b/opal/include/opal_config_bottom.hindex f906278..c2f1643 100644
--- a/opal/include/opal_config_bottom.h
+++ b/opal/include/opal_config_bottom.h
@@ -491,7 +491,14 @@ static inline uint16_t ntohs(uint16_t netvar) { return netvar; }
#include <hostLib.h>
#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
+/* From limits.h. Since we're using gethostname(), we add 1 to the max to allow
+ * for null termination.
+ */
+#ifdef HOST_NAME_MAX
+#define MAXHOSTNAMELEN HOST_NAME_MAX + 1
+#else
+#define MAXHOSTNAMELEN 64 + 1
+#endif
#endif
#endif
and sift through all callers of gethostname(). I have some concerns though:
- I'm probably going to be stomping on components that may have an 'upstream' somewhere?
- Non-POSIX systems might have some issue with this?
Perhaps this is barking up the wrong tree?
Metadata
Metadata
Assignees
Labels
No labels