Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cirrus: Mark gocritic linter as mandatory #102

Merged
merged 4 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ task:
GOLANGCI_ARGS: "--new-from-rev=HEAD~"
- name: Go Lint Mandatory
env:
GOLANGCI_ARGS: "--disable=cyclop,dupl,errcheck,errname,errorlint,exhaustive,funlen,gci,gocritic,godox,goerr113,gofmt,gofumpt,goimports,golint,gomnd,gosimple,govet,ifshort,lll,makezero,nestif,nlreturn,nosnakecase,paralleltest,revive,stylecheck,thelper,unconvert,varnamelen,wrapcheck,wsl"
GOLANGCI_ARGS: "--disable=cyclop,dupl,errcheck,errname,errorlint,exhaustive,funlen,gci,godox,goerr113,gofmt,gofumpt,goimports,golint,gomnd,gosimple,govet,ifshort,lll,makezero,nestif,nlreturn,nosnakecase,paralleltest,revive,stylecheck,thelper,unconvert,varnamelen,wrapcheck,wsl"
- name: Go Lint
env:
GOLANGCI_ARGS: ""
Expand Down
10 changes: 7 additions & 3 deletions p11mod/p11mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,18 @@ func (ll *llBackend) GetTokenInfo(slotID uint) (pkcs11.TokenInfo, error) {
}

func (ll *llBackend) GetMechanismList(slotID uint) ([]*pkcs11.Mechanism, error) {
//slot, err := ll.getSlotByID(slotID)
_, err := ll.getSlotByID(slotID)
slot, err := ll.getSlotByID(slotID)
if err != nil {
return []*pkcs11.Mechanism{}, err
}

_, err = slot.Mechanisms()
if err != nil {
return []*pkcs11.Mechanism{}, err
}

// TODO
log.Println("p11mod GetMechanismList: not implemented")
log.Println("p11mod GetMechanismList: not implemented, see https://github.com/miekg/pkcs11/issues/158")
return []*pkcs11.Mechanism{}, nil
}

Expand Down
9 changes: 5 additions & 4 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func toTemplate(clist C.CK_ATTRIBUTE_PTR, size C.CK_ULONG) []*pkcs11.Attribute {
if int(c.ulValueLen) != -1 {
buf := unsafe.Pointer(C.getAttributePval(c))
x.Value = C.GoBytes(buf, C.int(c.ulValueLen))
//C.free(buf) // Removed compared to miekg implementation since it's not desired here
// C.free(buf) // Removed compared to miekg implementation since it's not desired here
}
l2[i] = x
}
Expand All @@ -142,17 +142,18 @@ func fromTemplate(template []*pkcs11.Attribute, clist C.CK_ATTRIBUTE_PTR) error
continue
}
cLen := C.CK_ULONG(uint(len(x.Value)))
if C.getAttributePval(c) == nil {
switch {
case C.getAttributePval(c) == nil:
c.ulValueLen = cLen
} else if c.ulValueLen >= cLen {
case c.ulValueLen >= cLen:
buf := unsafe.Pointer(C.getAttributePval(c))

// Adapted from solution 3 of https://stackoverflow.com/a/35675259
goBuf := (*[1 << 30]byte)(buf)
copy(goBuf[:], x.Value)

c.ulValueLen = cLen
} else {
default:
c.ulValueLen = C.CK_UNAVAILABLE_INFORMATION
bufferTooSmall = true
}
Expand Down