Browse Source

Fix buffer overflow for large 64-bit numbers

master
NGnius (Graham) 4 years ago
parent
commit
29e97ceaad
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      sql_structs.go

+ 4
- 4
sql_structs.go View File

@@ -372,7 +372,7 @@ func (k *Key) Develop() {
}

func (k *Key) GenerateToken() error {
buf_int64 := make([]byte, 8) // 8 bytes = 64 bits
buf_int64 := make([]byte, 10) // 8 bytes = 64 bits
input := []byte{}
if randomizeTokens {
max := big.NewInt(2 ^ 16 - 1)
@@ -383,11 +383,11 @@ func (k *Key) GenerateToken() error {
}
}
binary.PutVarint(buf_int64, k.ID)
input = append(input, buf_int64...)
input = append(input, buf_int64[0:8]...)
binary.PutVarint(buf_int64, k.Player)
input = append(input, buf_int64...)
input = append(input, buf_int64[0:8]...)
binary.PutVarint(buf_int64, k.Time)
input = append(input, buf_int64...)
input = append(input, buf_int64[0:8]...)
bToken := sha512.Sum512(input)
//k.Token = string(bToken)
k.Token = ""