From patchwork Fri Jul 19 21:26:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Lovenberg X-Patchwork-Id: 2830706 Return-Path: X-Original-To: patchwork-cifs-client@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 9578A9F4D5 for ; Fri, 19 Jul 2013 21:26:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B67820208 for ; Fri, 19 Jul 2013 21:26:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7359120207 for ; Fri, 19 Jul 2013 21:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109Ab3GSV0T (ORCPT ); Fri, 19 Jul 2013 17:26:19 -0400 Received: from mail-yh0-f46.google.com ([209.85.213.46]:36347 "EHLO mail-yh0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805Ab3GSV0S (ORCPT ); Fri, 19 Jul 2013 17:26:18 -0400 Received: by mail-yh0-f46.google.com with SMTP id i57so1689449yha.33 for ; Fri, 19 Jul 2013 14:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=eQaMuiGBFVRX8sEnzvaxoclAYdELXgJ4q+ITIv9zIZ8=; b=aNbs0/skBt+duppW6/xLGWopH8sM3kPEJ+HPZ5EZtvdhUMixXwy7aCcOmcCng3d/y1 U6mk5j9yaeT+D6sHkcO9IKNCZ6EcGUEO9mdN5jkexXPCa0fyEeQLqEWTYHJ9AHX1tMis X6nZVyEm4eEwMGH1uyPr1A4QygoA3/ez8dzkjb0k/KTNqPEcVEI/qCkJQom7sUqw9m28 D4xCUVLF8/GA4F/G+/cYgfvfi6iCj0xldRG2BPiZl3qkuhLC2jaJEhsFB6NWa+HJP4Ve /6WZ72aH2iAh3GzCHd/sQkAX47m7l4Jrh+eUV+UJmp7ibocDQBh3GBkE3nHbz1czfAyA jKUA== X-Received: by 10.236.123.210 with SMTP id v58mr10105962yhh.64.1374269177519; Fri, 19 Jul 2013 14:26:17 -0700 (PDT) Received: from nix.cleftstone.net ([64.9.42.64]) by mx.google.com with ESMTPSA id v68sm24105265yhn.22.2013.07.19.14.26.15 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 19 Jul 2013 14:26:16 -0700 (PDT) From: scott.lovenberg@gmail.com To: jlayton@redhat.com Cc: Scott Lovenberg , gang.chen@asianux.com, sfrench@samba.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH] cifs-utils: Correct max string lengths Date: Fri, 19 Jul 2013 17:26:12 -0400 Message-Id: <1374269172-4964-1-git-send-email-scott.lovenberg@gmail.com> X-Mailer: git-send-email 1.8.1.4 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Scott Lovenberg The max size of the username, domain, password and share name strings are now consistent with the kernel and Microsoft's documentation. Signed-off-by: Scott Lovenberg --- AUTHORS | 2 ++ mount.cifs.c | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2807079..2f6a14d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,5 +5,7 @@ Shirish Pargaonkar Suresh Jayaraman Pavel Shilovsky Igor Druzhinin +Scott Lovenberg + ...and others. diff --git a/mount.cifs.c b/mount.cifs.c index 3b2b89e..8d975b3 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -83,22 +83,31 @@ /* max length of mtab options */ #define MTAB_OPTIONS_LEN 220 -/* - * Maximum length of "share" portion of a UNC. I have no idea if this is at - * all valid. According to MSDN, the typical max length of any component is - * 255, so use that here. +/* + * Max share name, username, password and domain sizes match the kernel's + * allowances for these string sizes which in turn match Microsoft's + * documentation. */ -#define MAX_SHARE_LEN 256 -/* max length of username (somewhat made up here) */ -#define MAX_USERNAME_SIZE 32 +/* Max length of the share name portion of a UNC. According to Microsoft + * this is correct for Windows 2000/XP. */ +#define MAX_SHARE_LEN 80 + +/* Max user name length. */ +#define MAX_USERNAME_SIZE 256 + +/* Max domain size. */ +#define MAX_DOMAIN_SIZE 256 + +/* Max password size. */ +#define MOUNT_PASSWD_SIZE 512 + + #ifndef SAFE_FREE #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x = NULL; } } while (0) #endif -#define MOUNT_PASSWD_SIZE 128 -#define MAX_DOMAIN_SIZE 64 /* * mount.cifs has been the subject of many "security" bugs that have arisen