diff mbox

Removed magic number for max username in parse_options.

Message ID 1272549497-6578-2-git-send-email-scott.lovenberg@gmail.com
State New
Headers show

Commit Message

Scott Lovenberg April 29, 2010, 1:58 p.m. UTC
Replaced max username in parse_options with the sum of its potential parts for "domain/user%password" formatted values.  Note that forward slashes still expand to a double back slash in the parse_username function, though.

Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
---
 mount.cifs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Comments

Jeff Layton May 11, 2010, 1:34 p.m. UTC | #1
On Thu, 29 Apr 2010 09:58:17 -0400
Scott Lovenberg <scott.lovenberg@gmail.com> wrote:

> Replaced max username in parse_options with the sum of its potential parts for "domain/user%password" formatted values.  Note that forward slashes still expand to a double back slash in the parse_username function, though.
> 
> Signed-off-by: Scott Lovenberg <scott.lovenberg@gmail.com>
> ---
>  mount.cifs.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/mount.cifs.c b/mount.cifs.c
> index 155d594..c1944ac 100644
> --- a/mount.cifs.c
> +++ b/mount.cifs.c
> @@ -858,7 +858,11 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info)
>  					return EX_USAGE;
>  				}
>  			} else {
> -				if (strnlen(value, 260) >= 260) {
> +				/* domain/username%password */
> +				const int max = MAX_DOMAIN_SIZE +
> +						MAX_USERNAME_SIZE +
> +						MOUNT_PASSWD_SIZE + 2;
> +				if (strnlen(value, max + 1) >= max + 1) {
>  					fprintf(stderr, "username too long\n");
>  					return EX_USAGE;
>  				}

Looks good. Committed.

Thanks,
diff mbox

Patch

diff --git a/mount.cifs.c b/mount.cifs.c
index 155d594..c1944ac 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -858,7 +858,11 @@  parse_options(const char *data, struct parsed_mount_info *parsed_info)
 					return EX_USAGE;
 				}
 			} else {
-				if (strnlen(value, 260) >= 260) {
+				/* domain/username%password */
+				const int max = MAX_DOMAIN_SIZE +
+						MAX_USERNAME_SIZE +
+						MOUNT_PASSWD_SIZE + 2;
+				if (strnlen(value, max + 1) >= max + 1) {
 					fprintf(stderr, "username too long\n");
 					return EX_USAGE;
 				}