Maximum password length check too short in mount.cifs
[sfrench/samba-autobuild/.git] / source3 / client / mount.cifs.c
index 641584947ff6b62c9e6ed7b4384945d8e3d85884..a5d99dc3d918dc53c17b48f6463efb998b70a128 100644 (file)
@@ -77,7 +77,7 @@
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
 #endif
 
-#define MOUNT_PASSWD_SIZE 64
+#define MOUNT_PASSWD_SIZE 128
 #define DOMAIN_SIZE 64
 
 /* currently maximum length of IPv6 address string */
@@ -473,7 +473,7 @@ static int parse_options(char ** optionsp, int * filesys_flags)
                                        printf("\npassword specified twice, ignoring second\n");
                                } else
                                        got_password = 1;
-                       } else if (strnlen(value, 17) < 17) {
+                       } else if (strnlen(value, MOUNT_PASSWD_SIZE) < MOUNT_PASSWD_SIZE) {
                                if(got_password)
                                        printf("\nmount.cifs warning - password specified twice\n");
                                got_password = 1;
@@ -649,7 +649,9 @@ static int parse_options(char ** optionsp, int * filesys_flags)
                } else if (strncmp(data, "exec", 4) == 0) {
                        *filesys_flags &= ~MS_NOEXEC;
                } else if (strncmp(data, "guest", 5) == 0) {
-                       got_password=1;
+                       user_name = (char *)calloc(1, 1);
+                       got_user = 1;
+                       got_password = 1;
                } else if (strncmp(data, "ro", 2) == 0) {
                        *filesys_flags |= MS_RDONLY;
                } else if (strncmp(data, "rw", 2) == 0) {
@@ -1016,6 +1018,14 @@ uppercase_string(char *string)
        return 1;
 }
 
+static void print_cifs_mount_version(void)
+{
+       printf("mount.cifs version: %s.%s%s\n",
+               MOUNT_CIFS_VERSION_MAJOR,
+               MOUNT_CIFS_VERSION_MINOR,
+               MOUNT_CIFS_VENDOR_SUFFIX);
+}
+
 int main(int argc, char ** argv)
 {
        int c;
@@ -1077,6 +1087,24 @@ int main(int argc, char ** argv)
                        exit(EX_SYSERR);
                }
                mountpoint = argv[2];
+       } else if (argc == 2) {
+               if ((strcmp(argv[1], "-V") == 0) ||
+                   (strcmp(argv[1], "--version") == 0))
+               {
+                       print_cifs_mount_version();
+                       exit(0);
+               }
+
+               if ((strcmp(argv[1], "-h") == 0) ||
+                   (strcmp(argv[1], "-?") == 0) ||
+                   (strcmp(argv[1], "--help") == 0))
+               {
+                       mount_cifs_usage();
+                       exit(0);
+               }
+
+               mount_cifs_usage();
+               exit(EX_USAGE);
        } else {
                mount_cifs_usage();
                exit(EX_USAGE);
@@ -1133,11 +1161,8 @@ int main(int argc, char ** argv)
                case 'v':
                        ++verboseflag;
                        break;
-               case 'V':          
-                       printf ("mount.cifs version: %s.%s%s\n",
-                       MOUNT_CIFS_VERSION_MAJOR,
-                       MOUNT_CIFS_VERSION_MINOR,
-                       MOUNT_CIFS_VENDOR_SUFFIX);
+               case 'V':
+                       print_cifs_mount_version();
                        exit (0);
                case 'w':
                        flags &= ~MS_RDONLY;
@@ -1438,7 +1463,8 @@ mount_retry:
                        }
                }
                printf("mount error(%d): %s\n", errno, strerror(errno));
-               printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n");
+               printf("Refer to the mount.cifs(8) manual page (e.g. man "
+                      "mount.cifs)\n");
                rc = EX_FAIL;
                goto mount_exit;
        }