Message ID | 1387397189-9591-1-git-send-email-tasleson@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 18/12/13 15:06, Tony Asleson wrote: > 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> All three committed... steved. > --- > 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; > -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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;
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> --- utils/exportfs/exportfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)