Skip to content

Commit a5dd82e

Browse files
committed
session: trim or pad session key to 16 bytes
1 parent 607bcb5 commit a5dd82e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

session.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ func sessionSetup(conn *conn, i Initiator, ctx context.Context) (*session, error
129129
}
130130

131131
if s.sessionFlags&(SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL) == 0 {
132-
sessionKey := i.SessionKey()
132+
133+
sessionKey := padSessionKey(i.SessionKey())
133134

134135
switch conn.dialect {
135136
case SMB202, SMB210:
@@ -256,6 +257,12 @@ func sessionSetup(conn *conn, i Initiator, ctx context.Context) (*session, error
256257
return s, nil
257258
}
258259

260+
func padSessionKey(key []byte) []byte {
261+
newKey := make([]byte, 16)
262+
copy(newKey, key)
263+
return newKey
264+
}
265+
259266
type session struct {
260267
*conn
261268
treeConnTables map[uint32]*treeConn

0 commit comments

Comments
 (0)