From ed9a3b7165ae2300ebb185ca53e698e5ef93173b Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 29 May 2020 10:36:13 -0600 Subject: [PATCH] util: Fix segfault in the func ConstructLocalPath The function ConstructLocalPath will segfault if passed a NULL for the command path parameter. Update ConstructLocalPath to test the passed command path for a NULL and return ENOENT. The segfault can be triggered by setting up a BosConfig with a dafs bnode that does not contain all the required parms. This setup results in bosserver segfaulting. With the fix, bosserver now logs an error and exits cleanly. Change-Id: I26015c8accd829f3101b073964777b41d16b07f7 Reviewed-on: https://gerrit.openafs.org/14223 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/util/dirpath.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/dirpath.c b/src/util/dirpath.c index 3957611b90..830ac26315 100644 --- a/src/util/dirpath.c +++ b/src/util/dirpath.c @@ -560,6 +560,9 @@ ConstructLocalPath(const char *cpath, const char *relativeTo, *fullPathBufp = NULL; + if (cpath == NULL) + return ENOENT; + while (isspace(*cpath)) { cpath++; } @@ -654,6 +657,9 @@ ConstructLocalPath(const char *cpath, const char *relativeTo, *fullPathBufp = NULL; + if (cpath == NULL) + return ENOENT; + while (isspace(*cpath)) { cpath++; }