Skip to content

Commit 94fc0d0

Browse files
authored
Merge pull request #1160 from markbrown314/issue-1159
Fixed Off-by-one error in gethostname()
2 parents 45e6e7e + c75c0eb commit 94fc0d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/runtime_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int shmem_runtime_util_put_hostname(void)
8989
char hostname[MAX_HOSTNAME_LEN+1];
9090
int ret;
9191

92-
ret = gethostname(hostname, MAX_HOSTNAME_LEN);
92+
ret = gethostname(hostname, MAX_HOSTNAME_LEN+1);
9393
if (ret != 0) {
9494
RETURN_ERROR_MSG("gethostname failed (%d)", ret);
9595
return ret;
@@ -123,7 +123,7 @@ int shmem_runtime_util_populate_node(int *location_array, int size, int *node_si
123123
int ret, i, n_node_pes = 0;
124124
char hostname[MAX_HOSTNAME_LEN+1];
125125

126-
ret = gethostname(hostname, MAX_HOSTNAME_LEN);
126+
ret = gethostname(hostname, MAX_HOSTNAME_LEN+1);
127127
if (ret != 0) {
128128
RETURN_ERROR_MSG("gethostname failed (%d)", ret);
129129
return ret;

0 commit comments

Comments
 (0)