[ofa-general] [PATCH 6/6] [DAPL v2] fix gethostname handling

Patrick Marchand Latifi patrick.latifi at qlogic.com
Tue Feb 19 03:19:42 PST 2008


Guarantee NUL termination if hostname gets truncated.

Signed-off-by: Patrick Marchand Latifi <patrick.latifi at qlogic.com>
---

 dapl/common/dapl_ia_open.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/dapl/common/dapl_ia_open.c b/dapl/common/dapl_ia_open.c
index a780a98..d85c1b6 100644
--- a/dapl/common/dapl_ia_open.c
+++ b/dapl/common/dapl_ia_open.c
@@ -395,6 +395,10 @@ dapli_assign_hca_ip_address (
      */
 
     rc = gethostname (hostname, NAMELEN);
+
+    /* guarantee NUL termination if hostname gets truncated */
+    hostname[NAMELEN-1] = '\0';
+
     /*
      * Strip off domain info if it exists (e.g. mynode.mydomain.com)
      */




More information about the general mailing list