cifs: replace some hardcoded values with preprocessor constants
A number of places that deal with RFC1001/1002 negotiations have bare "15" or "16" values. Replace them with RFC_1001_NAME_LEN and RFC_1001_NAME_LEN_WITH_NULL. The patch also cleans up some checkpatch warnings for code surrounding the changes. This should apply cleanly on top of the patch to remove Local_System_Name. Reported-and-Reviwed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
a0f8b4fb4c
commit
1397f2ee4b
1 changed files with 19 additions and 18 deletions
|
@ -64,8 +64,8 @@ struct smb_vol {
|
||||||
char *UNC;
|
char *UNC;
|
||||||
char *UNCip;
|
char *UNCip;
|
||||||
char *iocharset; /* local code page for mapping to and from Unicode */
|
char *iocharset; /* local code page for mapping to and from Unicode */
|
||||||
char source_rfc1001_name[16]; /* netbios name of client */
|
char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
|
||||||
char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */
|
char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
|
||||||
uid_t cred_uid;
|
uid_t cred_uid;
|
||||||
uid_t linux_uid;
|
uid_t linux_uid;
|
||||||
gid_t linux_gid;
|
gid_t linux_gid;
|
||||||
|
@ -816,11 +816,11 @@ cifs_parse_mount_options(char *options, const char *devname,
|
||||||
* informational, only used for servers that do not support
|
* informational, only used for servers that do not support
|
||||||
* port 445 and it can be overridden at mount time
|
* port 445 and it can be overridden at mount time
|
||||||
*/
|
*/
|
||||||
memset(vol->source_rfc1001_name, 0x20, 15);
|
memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
|
||||||
for (i = 0; i < strnlen(nodename, 15); i++)
|
for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++)
|
||||||
vol->source_rfc1001_name[i] = toupper(nodename[i]);
|
vol->source_rfc1001_name[i] = toupper(nodename[i]);
|
||||||
|
|
||||||
vol->source_rfc1001_name[15] = 0;
|
vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
|
||||||
/* null target name indicates to use *SMBSERVR default called name
|
/* null target name indicates to use *SMBSERVR default called name
|
||||||
if we end up sending RFC1001 session initialize */
|
if we end up sending RFC1001 session initialize */
|
||||||
vol->target_rfc1001_name[0] = 0;
|
vol->target_rfc1001_name[0] = 0;
|
||||||
|
@ -1167,22 +1167,22 @@ cifs_parse_mount_options(char *options, const char *devname,
|
||||||
if (!value || !*value || (*value == ' ')) {
|
if (!value || !*value || (*value == ' ')) {
|
||||||
cFYI(1, "invalid (empty) netbiosname");
|
cFYI(1, "invalid (empty) netbiosname");
|
||||||
} else {
|
} else {
|
||||||
memset(vol->source_rfc1001_name, 0x20, 15);
|
memset(vol->source_rfc1001_name, 0x20,
|
||||||
for (i = 0; i < 15; i++) {
|
RFC1001_NAME_LEN);
|
||||||
/* BB are there cases in which a comma can be
|
/*
|
||||||
valid in this workstation netbios name (and need
|
* FIXME: are there cases in which a comma can
|
||||||
special handling)? */
|
* be valid in workstation netbios name (and
|
||||||
|
* need special handling)?
|
||||||
/* We do not uppercase netbiosname for user */
|
*/
|
||||||
|
for (i = 0; i < RFC1001_NAME_LEN; i++) {
|
||||||
|
/* don't ucase netbiosname for user */
|
||||||
if (value[i] == 0)
|
if (value[i] == 0)
|
||||||
break;
|
break;
|
||||||
else
|
vol->source_rfc1001_name[i] = value[i];
|
||||||
vol->source_rfc1001_name[i] =
|
|
||||||
value[i];
|
|
||||||
}
|
}
|
||||||
/* The string has 16th byte zero still from
|
/* The string has 16th byte zero still from
|
||||||
set at top of the function */
|
set at top of the function */
|
||||||
if ((i == 15) && (value[i] != 0))
|
if (i == RFC1001_NAME_LEN && value[i] != 0)
|
||||||
printk(KERN_WARNING "CIFS: netbiosname"
|
printk(KERN_WARNING "CIFS: netbiosname"
|
||||||
" longer than 15 truncated.\n");
|
" longer than 15 truncated.\n");
|
||||||
}
|
}
|
||||||
|
@ -1192,7 +1192,8 @@ cifs_parse_mount_options(char *options, const char *devname,
|
||||||
cFYI(1, "empty server netbiosname specified");
|
cFYI(1, "empty server netbiosname specified");
|
||||||
} else {
|
} else {
|
||||||
/* last byte, type, is 0x20 for servr type */
|
/* last byte, type, is 0x20 for servr type */
|
||||||
memset(vol->target_rfc1001_name, 0x20, 16);
|
memset(vol->target_rfc1001_name, 0x20,
|
||||||
|
RFC1001_NAME_LEN_WITH_NULL);
|
||||||
|
|
||||||
for (i = 0; i < 15; i++) {
|
for (i = 0; i < 15; i++) {
|
||||||
/* BB are there cases in which a comma can be
|
/* BB are there cases in which a comma can be
|
||||||
|
@ -1209,7 +1210,7 @@ cifs_parse_mount_options(char *options, const char *devname,
|
||||||
}
|
}
|
||||||
/* The string has 16th byte zero still from
|
/* The string has 16th byte zero still from
|
||||||
set at top of the function */
|
set at top of the function */
|
||||||
if ((i == 15) && (value[i] != 0))
|
if (i == RFC1001_NAME_LEN && value[i] != 0)
|
||||||
printk(KERN_WARNING "CIFS: server net"
|
printk(KERN_WARNING "CIFS: server net"
|
||||||
"biosname longer than 15 truncated.\n");
|
"biosname longer than 15 truncated.\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue