From d78ee9f95fbe48f71eb247b01c598994edfa4d17 Mon Sep 17 00:00:00 2001 From: Patrick Marchand Latifi Date: Tue, 19 Feb 2008 03:19:42 -0800 Subject: [PATCH] Guarantee NUL termination if hostname gets truncated. Signed-off-by: Patrick Marchand Latifi --- dapl/common/dapl_ia_open.c | 4 ++++ 1 file changed, 4 insertions(+) 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) */ -- 2.46.0