Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix: invalid token cause crash
Browse files Browse the repository at this point in the history
  • Loading branch information
aiwantaozi committed Aug 15, 2023
1 parent 3953b76 commit c3a01f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions staging/utils/cryptox/encryptor_aesgcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
)

Expand Down Expand Up @@ -50,6 +51,11 @@ func (e aesGcmEncryptor) Decrypt(c, a []byte) ([]byte, error) {
if err != nil {
return nil, err
}

if len(c) < g.NonceSize() {
return nil, fmt.Errorf("too short")
}

n := c[:g.NonceSize()]
c = c[g.NonceSize():]

Expand Down

0 comments on commit c3a01f1

Please sign in to comment.