From c5c1e71cc81b5c4cb5b29f8092186d4ad55db49a Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Tue, 5 Sep 2017 17:14:18 -0700 Subject: [PATCH] test: add bounds check for nfs test The nfs test builds a list of entries for all mount points on the system, and then checks each mount point for expected results against the opal_path_nfs() call. This test assumed that there were less than 256 mount points on the system, which apparently isn't true on some Cray systems. This patch makes two changes: add the proper bound check to avoid a segmentation fault and double the list of mount points we'll return. Signed-off-by: Brian Barrett --- test/util/opal_path_nfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/util/opal_path_nfs.c b/test/util/opal_path_nfs.c index e2405bdefe4..cd361dc1f3f 100644 --- a/test/util/opal_path_nfs.c +++ b/test/util/opal_path_nfs.c @@ -132,7 +132,7 @@ void test(char* file, bool expect) void get_mounts (int * num_dirs, char ** dirs[], bool * nfs[]) { -#define MAX_DIR 256 +#define MAX_DIR 512 #define SIZE 1024 char * cmd = "mount | cut -f3,5 -d' ' > opal_path_nfs.out"; int rc; @@ -156,7 +156,7 @@ void get_mounts (int * num_dirs, char ** dirs[], bool * nfs[]) file = fopen("opal_path_nfs.out", "r"); i = 0; rc = 4711; - while (NULL != fgets (buffer, SIZE, file)) { + while (i < MAX_DIR && NULL != fgets (buffer, SIZE, file)) { int mount_known; char fs[MAXNAMLEN];