From a16bd280fd17b8ff64f9bfd6ee17c94649eaa09a Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 30 Jan 2009 08:46:38 -0800 Subject: [PATCH] Fix a string parsing bug when trying to run hammer pfs-master on a subdirectory of the root directory, e.g. "hammer pfs-master /fubar". Reported-by: "Simon 'corecode' Schubert" --- sbin/hammer/cmd_pseudofs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sbin/hammer/cmd_pseudofs.c b/sbin/hammer/cmd_pseudofs.c index eb58454321..67933ec7a1 100644 --- a/sbin/hammer/cmd_pseudofs.c +++ b/sbin/hammer/cmd_pseudofs.c @@ -207,9 +207,17 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave) exit(1); } + /* + * Figure out the directory prefix, taking care of degenerate + * cases. + */ dirpath = strdup(path); if (strrchr(dirpath, '/') != NULL) { *strrchr(dirpath, '/') = 0; + if (dirpath[0] == 0) { + free(dirpath); + dirpath = strdup("/"); + } } else { free(dirpath); dirpath = strdup("."); -- 2.11.4.GIT