Skip to content

Commit

Permalink
tds: fix password encryption for ASE 16.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thda committed Jun 16, 2020
1 parent ea69ac8 commit f49ccc1
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 61 deletions.
1 change: 0 additions & 1 deletion buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ func (b *buf) receive(s *state) stateFn {
// check if the message is in the ones to return
// and attempt to skip if not found
msg, ok := b.defaultMessageMap[s.t]

// look in provided message map
if !ok {
msg, ok = s.msg[s.t]
Expand Down
10 changes: 10 additions & 0 deletions changetype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions columnflag_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 105 additions & 50 deletions datatype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
noneToken token = 0x00
capabilityReqToken token = 0x01
capabilityResToken token = 0x02
paramFmt2Toekn token = 0x20 // 32
paramFmt2Token token = 0x20 // 32
languageToken token = 0x21 // 33
orderBy2Token token = 0x22 // 34
wideColumnFmtToken token = 0x61 // 97
Expand Down Expand Up @@ -98,7 +98,7 @@ var msgs = map[token]msg{
noneToken: {noneToken, noFlag, 0},
capabilityReqToken: {capabilityReqToken, noFlag, 0},
capabilityResToken: {capabilityResToken, noFlag, 0},
paramFmt2Toekn: {paramFmt2Toekn, long, 0},
paramFmt2Token: {paramFmt2Token, long, 0},
languageToken: {languageToken, ignoreSize, 0},
orderBy2Token: {orderBy2Token, long, 0},
cmpRowFmtToken: {cmpRowFmtToken, noFlag, 0},
Expand Down
14 changes: 14 additions & 0 deletions packettype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var rowPool = sync.Pool{
columnFmtToken: rows.columns,
// params are handled like rows
paramToken: rows.row,
paramFmt2Toekn: rows.wideParams,
paramFmt2Token: rows.wideParams,
paramFmtToken: rows.params,
columnInfoToken: rows.columnsInfo,
tableNameToken: rows.tableName,
Expand Down Expand Up @@ -196,14 +196,14 @@ func (r *Rows) Next(dest []driver.Value) (err error) {
return nil
case tableNameToken, columnInfoToken, doneToken:
return r.Next(dest)
case wideColumnFmtToken, columnFmtToken, paramFmtToken, paramFmt2Toekn:
case wideColumnFmtToken, columnFmtToken, paramFmtToken, paramFmt2Token:
switch t {
case wideColumnFmtToken:
r.row.columns = r.wideColumns.fmts
case columnFmtToken:
r.row.columns = r.columns.fmts
// ignore parameters
case paramFmt2Toekn:
case paramFmt2Token:
r.row.columns = r.wideParams.fmts
return r.Next(dest)
case paramFmtToken:
Expand Down
9 changes: 7 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (s *session) login(prm connParams) (err error) {

loginAck := &loginAck{msg: newMsg(loginAckToken)}
pf := &columns{msg: newMsg(paramFmtToken)}
wpf := &columns{msg: newMsg(paramFmt2Token), flags: wide | param}
p := &row{msg: newMsg(paramToken)}

// only retry once
Expand All @@ -199,10 +200,14 @@ loginResponse:
map[token]messageReader{loginAckToken: loginAck,
capabilitiesToken: &s.capabilities,
paramFmtToken: pf,
paramFmt2Token: wpf,
paramToken: p}); f != nil; f = f(s.state) {
if s.state.t == paramFmtToken {
// bind the param descriptor and the param
switch s.state.t {
// bind the param descriptor and the param
case paramFmtToken:
p.columns = pf.fmts
case paramFmt2Token:
p.columns = wpf.fmts
}
}

Expand Down
4 changes: 2 additions & 2 deletions stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newStmt(ctx context.Context, s *session, query string) (*Stmt, error) {
}

params := &columns{msg: newMsg(paramFmtToken), flags: param}
wideParams := &columns{msg: newMsg(paramFmt2Toekn), flags: wide | param}
wideParams := &columns{msg: newMsg(paramFmt2Token), flags: wide | param}
st.row = &row{msg: newMsg(paramToken)}

// get a statement number
Expand All @@ -66,7 +66,7 @@ func newStmt(ctx context.Context, s *session, query string) (*Stmt, error) {
// the server will spew out a rowfmt, but it's safe to ignore it, it will be resent
for f := s.initState(ctx,
map[token]messageReader{dynamic2Token: st.d,
paramFmtToken: params, paramFmt2Toekn: wideParams}); f != nil; f = f(s.state) {
paramFmtToken: params, paramFmt2Token: wideParams}); f != nil; f = f(s.state) {
}

if err := s.checkErr(s.state.err, "tds: Prepare failed", true); err != nil {
Expand Down
48 changes: 47 additions & 1 deletion token_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f49ccc1

Please sign in to comment.