diff mbox

exportfs: Don't buffer overflow on exports that are too big.

Message ID 1389206830-5368-1-git-send-email-steved@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Steve Dickson Jan. 8, 2014, 6:47 p.m. UTC
Signe-doff-by: Steve Dickson <steved@redhat.com>
---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Steve Dickson Jan. 20, 2014, 10:02 p.m. UTC | #1
On 08/01/14 13:47, Steve Dickson wrote:
> Signe-doff-by: Steve Dickson <steved@redhat.com>
Committed...

steved.

> ---
>  utils/exportfs/exportfs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index 9ea86cb..8c86790 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -452,6 +452,8 @@ static int test_export(char *path, int with_fsid)
>  	bp += n;
>  	len -= n;
>  	qword_add(&bp, &len, path);
> +	if (len < 1)
> +		return 0;
>  	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)
> 
--
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 mbox

Patch

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 9ea86cb..8c86790 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -452,6 +452,8 @@  static int test_export(char *path, int with_fsid)
 	bp += n;
 	len -= n;
 	qword_add(&bp, &len, path);
+	if (len < 1)
+		return 0;
 	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)