From: Matthew Dillon Date: Fri, 30 Jan 2009 16:46:38 +0000 (-0800) Subject: Fix a string parsing bug when trying to run hammer pfs-master on a X-Git-Tag: v2.3.0~8 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/a16bd280fd17b8ff64f9bfd6ee17c94649eaa09a 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" --- 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(".");