From patchwork Wed Jan 8 18:47:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 3455451 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C7E69F1C4 for ; Wed, 8 Jan 2014 18:45:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B24DA20108 for ; Wed, 8 Jan 2014 18:45:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1C9E200F3 for ; Wed, 8 Jan 2014 18:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752274AbaAHSpY (ORCPT ); Wed, 8 Jan 2014 13:45:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10343 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751089AbaAHSpY (ORCPT ); Wed, 8 Jan 2014 13:45:24 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s08IjNaJ010638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 8 Jan 2014 13:45:23 -0500 Received: from smallhat.boston.devel.redhat.com (smallhat.boston.devel.redhat.com [10.19.60.65]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s08IjNP2032080 for ; Wed, 8 Jan 2014 13:45:23 -0500 From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH] exportfs: Don't buffer overflow on exports that are too big. Date: Wed, 8 Jan 2014 13:47:10 -0500 Message-Id: <1389206830-5368-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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.0 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 Signe-doff-by: Steve Dickson --- 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)