From patchwork Sun Mar 21 19:20:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 48232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by ozlabs.org (Postfix) with ESMTP id 03678B7CEF for ; Mon, 22 Mar 2010 06:20:55 +1100 (EST) Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id A04E8AD22A; Sun, 21 Mar 2010 13:20:55 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=3.8 tests=AWL, BAYES_00, NO_MORE_FUNN, SPF_PASS autolearn=no version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.123]) by lists.samba.org (Postfix) with ESMTP id A3001AD1C3 for ; Sun, 21 Mar 2010 13:20:30 -0600 (MDT) X-Authority-Analysis: v=1.0 c=1 a=ZVTFXwHcM3EA:10 a=20KFwNOVAAAA:8 a=gU_tdxwuhMRaLKOb6r0A:9 a=jMk9OHw9Tr5Blvfp522FMwEyxwkA:4 a=jEp0ucaQiEUA:10 X-Cloudmark-Score: 0 X-Originating-IP: 71.70.153.3 Received: from [71.70.153.3] ([71.70.153.3:53424] helo=mail.poochiereds.net) by cdptpa-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.2.39 r()) with ESMTP id 6F/E5-06757-C7176AB4; Sun, 21 Mar 2010 19:20:28 +0000 Received: by mail.poochiereds.net (Postfix, from userid 4447) id CF18B5805F; Sun, 21 Mar 2010 15:20:27 -0400 (EDT) From: Jeff Layton To: linux-cifs-client@lists.samba.org Date: Sun, 21 Mar 2010 15:20:24 -0400 Message-Id: <1269199227-21446-8-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: References: Subject: [linux-cifs-client] [PATCH 07/10] mount.cifs: fix error handling when duplicating options string X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org Signed-off-by: Jeff Layton --- mount.cifs.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mount.cifs.c b/mount.cifs.c index 4631310..76cf851 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -57,6 +57,9 @@ #define MAX_UNC_LEN 1024 +/* I believe that the kernel limits options data to a page */ +#define MAX_OPTIONS_LEN 4096 + #ifndef SAFE_FREE #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) #endif @@ -1225,8 +1228,10 @@ int main(int argc, char ** argv) #endif break; case 'o': - orgoptions = strdup(optarg); - break; + orgoptions = strndup(optarg, MAX_OPTIONS_LEN); + if (!orgoptions) + exit(EX_SYSERR); + break; case 'r': /* mount readonly */ flags |= MS_RDONLY; break;