Skip to content

Commit

Permalink
fix: security alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Aug 3, 2023
1 parent b4cd7e8 commit e4b6dc6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions client/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func GenIMEI() string {
randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < 14; i++ { // generating all the base digits
toAdd := randGen.Intn(10)
fmt.Fprintf(&final, "%d", toAdd) // printing them here!
if (i+1)%2 == 0 { // special proc for every 2nd one
final.WriteString(strconv.Itoa(toAdd))
if (i+1)%2 == 0 { // special proc for every 2nd one
toAdd *= 2
if toAdd >= 10 {
toAdd = (toAdd % 10) + 1
Expand All @@ -102,7 +102,7 @@ func GenIMEI() string {
sum += toAdd // and even add them here!
}
ctrlDigit := (sum * 9) % 10 // calculating the control digit
fmt.Fprintf(&final, "%d", ctrlDigit)
final.WriteString(strconv.Itoa(ctrlDigit))
return final.String()
}

Expand Down
3 changes: 2 additions & 1 deletion client/internal/auth/qimei.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/aes"
"crypto/cipher"
"crypto/md5"
crand "crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
Expand Down Expand Up @@ -42,7 +43,7 @@ func (info *Device) RequestQImei() {

// init rsa key and aes key
publicKey := initPublicKey()
encryptedAesKey, _ := rsa.EncryptPKCS1v15(rand.New(rand.NewSource(time.Now().UnixNano())), publicKey, []byte(cryptKey))
encryptedAesKey, _ := rsa.EncryptPKCS1v15(crand.Reader, publicKey, []byte(cryptKey))

encryptedPayload := aesEncrypt(payload, []byte(cryptKey))

Expand Down
2 changes: 1 addition & 1 deletion topic/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func DecodeFeed(p *channel.StFeed) *Feed {
f.Contents = append(f.Contents, &TextElement{Content: c.TextContent.Text.Unwrap()})
}
if c.EmojiContent != nil {
id, _ := strconv.ParseInt(c.EmojiContent.Id.Unwrap(), 10, 64)
id, _ := strconv.ParseInt(c.EmojiContent.Id.Unwrap(), 10, 32)
f.Contents = append(f.Contents, &EmojiElement{
Index: int32(id),
Id: c.EmojiContent.Id.Unwrap(),
Expand Down

0 comments on commit e4b6dc6

Please sign in to comment.