summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2014-01-07 15:40:21 -0500
committerSteve Dickson <steved@redhat.com>2014-01-07 15:57:48 -0500
commitda915d0fff353c25524616e86647826877bb7c86 (patch)
treec98ed78a5b71bab19bb595a820b05800456c5009
parent93648ecc10bae7ed542056abb55f4b8f10ddbbb9 (diff)
downloadnfs-utils-da915d0fff353c25524616e86647826877bb7c86.tar.gz
nfs-utils-da915d0fff353c25524616e86647826877bb7c86.tar.xz
nfs-utils-da915d0fff353c25524616e86647826877bb7c86.zip
exportfs.c: escape path for function test_export
Verbatim patch proposal from J. Bruce Fields except calling snprintf instead of sprintf. Tested and appears to work with path names that have a space. Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/exportfs/exportfs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 00667e9..3ca45c1 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -444,11 +444,15 @@ static int can_test(void)
static int test_export(char *path, int with_fsid)
{
char buf[1024];
+ char *bp = buf;
+ int len = sizeof(buf);
int fd, n;
- sprintf(buf, "-test-client- %s 3 %d 65534 65534 0\n",
- path,
- with_fsid ? NFSEXP_FSID : 0);
+ n = snprintf(buf, len, "-test-client- ");
+ bp += n;
+ len -= n;
+ qword_add(&bp, &len, path);
+ snprintf(bp, len, " 3 %d 65534 65534 0\n", with_fsid ? NFSEXP_FSID : 0);
fd = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY);
if (fd < 0)
return 0;