Fix some off-by-one errors dealing with limits of server names,
usernames, workgroup names and passwords. We can now connect to servers with 15-character NetBIOS names. (Some versions of Windows use semi-random 15-char names by default.) PR: 46902
This commit is contained in:
parent
93e3ed5ab1
commit
5ec3441dd2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118079
@ -275,7 +275,7 @@ smb_ctx_setcharset(struct smb_ctx *ctx, const char *arg)
|
||||
int
|
||||
smb_ctx_setserver(struct smb_ctx *ctx, const char *name)
|
||||
{
|
||||
if (strlen(name) >= SMB_MAXSRVNAMELEN) {
|
||||
if (strlen(name) > SMB_MAXSRVNAMELEN) {
|
||||
smb_error("server name '%s' too long", 0, name);
|
||||
return ENAMETOOLONG;
|
||||
}
|
||||
@ -286,7 +286,7 @@ smb_ctx_setserver(struct smb_ctx *ctx, const char *name)
|
||||
int
|
||||
smb_ctx_setuser(struct smb_ctx *ctx, const char *name)
|
||||
{
|
||||
if (strlen(name) >= SMB_MAXUSERNAMELEN) {
|
||||
if (strlen(name) > SMB_MAXUSERNAMELEN) {
|
||||
smb_error("user name '%s' too long", 0, name);
|
||||
return ENAMETOOLONG;
|
||||
}
|
||||
@ -297,7 +297,7 @@ smb_ctx_setuser(struct smb_ctx *ctx, const char *name)
|
||||
int
|
||||
smb_ctx_setworkgroup(struct smb_ctx *ctx, const char *name)
|
||||
{
|
||||
if (strlen(name) >= SMB_MAXUSERNAMELEN) {
|
||||
if (strlen(name) > SMB_MAXUSERNAMELEN) {
|
||||
smb_error("workgroup name '%s' too long", 0, name);
|
||||
return ENAMETOOLONG;
|
||||
}
|
||||
@ -310,7 +310,7 @@ smb_ctx_setpassword(struct smb_ctx *ctx, const char *passwd)
|
||||
{
|
||||
if (passwd == NULL)
|
||||
return EINVAL;
|
||||
if (strlen(passwd) >= SMB_MAXPASSWORDLEN) {
|
||||
if (strlen(passwd) > SMB_MAXPASSWORDLEN) {
|
||||
smb_error("password too long", 0);
|
||||
return ENAMETOOLONG;
|
||||
}
|
||||
@ -325,7 +325,7 @@ smb_ctx_setpassword(struct smb_ctx *ctx, const char *passwd)
|
||||
int
|
||||
smb_ctx_setshare(struct smb_ctx *ctx, const char *share, int stype)
|
||||
{
|
||||
if (strlen(share) >= SMB_MAXSHARENAMELEN) {
|
||||
if (strlen(share) > SMB_MAXSHARENAMELEN) {
|
||||
smb_error("share name '%s' too long", 0, share);
|
||||
return ENAMETOOLONG;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user