From patchwork Wed Dec 18 20:06:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 3371641 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 88D04C0D4B for ; Wed, 18 Dec 2013 20:06:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76B9C205F9 for ; Wed, 18 Dec 2013 20:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F751205E9 for ; Wed, 18 Dec 2013 20:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751305Ab3LRUGb (ORCPT ); Wed, 18 Dec 2013 15:06:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52416 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750870Ab3LRUGa (ORCPT ); Wed, 18 Dec 2013 15:06:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBIK6TA5003986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 18 Dec 2013 15:06:30 -0500 Received: from tasleson.csb (vpn-229-185.phx2.redhat.com [10.3.229.185]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rBIK6Tk8026837 for ; Wed, 18 Dec 2013 15:06:29 -0500 Received: by tasleson.csb (Postfix, from userid 17209) id 3452644783; Wed, 18 Dec 2013 14:06:29 -0600 (CST) From: Tony Asleson To: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] exportfs.c: escape path for function test_export Date: Wed, 18 Dec 2013 14:06:27 -0600 Message-Id: <1387397189-9591-1-git-send-email-tasleson@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- utils/exportfs/exportfs.c | 10 +++++++--- 1 file 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;