Fix code security issue

This commit is contained in:
xuri 2021-07-20 23:04:50 +08:00
parent ec0ca8ba50
commit 1ec0207fb5
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
3 changed files with 9 additions and 13 deletions

View File

@ -7401,7 +7401,7 @@ func (fn *formulaFuncs) cumip(name string, argsList *list.List) formulaArg {
if start.Number < 1 || start.Number > end.Number {
return newErrorFormulaArg(formulaErrorNA, formulaErrorNA)
}
num, ipmt := 0.0, newNumberFormulaArg(0)
num := 0.0
for per := start.Number; per <= end.Number; per++ {
args := list.New().Init()
args.PushBack(rate)
@ -7411,11 +7411,10 @@ func (fn *formulaFuncs) cumip(name string, argsList *list.List) formulaArg {
args.PushBack(newNumberFormulaArg(0))
args.PushBack(typ)
if name == "CUMIPMT" {
ipmt = fn.IPMT(args)
} else {
ipmt = fn.PPMT(args)
num += fn.IPMT(args).Number
continue
}
num += ipmt.Number
num += fn.PPMT(args).Number
}
return newNumberFormulaArg(num)
}

5
lib.go
View File

@ -63,10 +63,7 @@ func (f *File) readXML(name string) []byte {
// saveFileList provides a function to update given file content in file list
// of XLSX.
func (f *File) saveFileList(name string, content []byte) {
newContent := make([]byte, 0, len(XMLHeader)+len(content))
newContent = append(newContent, []byte(XMLHeader)...)
newContent = append(newContent, content...)
f.Pkg.Store(name, newContent)
f.Pkg.Store(name, append([]byte(XMLHeader), content...))
}
// Read file content as string in a archive file.

View File

@ -3130,11 +3130,11 @@ func ThemeColor(baseColor string, tint float64) string {
if tint == 0 {
return "FF" + baseColor
}
r, _ := strconv.ParseInt(baseColor[0:2], 16, 64)
g, _ := strconv.ParseInt(baseColor[2:4], 16, 64)
b, _ := strconv.ParseInt(baseColor[4:6], 16, 64)
r, _ := strconv.ParseUint(baseColor[0:2], 16, 64)
g, _ := strconv.ParseUint(baseColor[2:4], 16, 64)
b, _ := strconv.ParseUint(baseColor[4:6], 16, 64)
var h, s, l float64
if r >= 0 && r <= math.MaxUint8 && g >= 0 && g <= math.MaxUint8 && b >= 0 && b <= math.MaxUint8 {
if r <= math.MaxUint8 && g <= math.MaxUint8 && b <= math.MaxUint8 {
h, s, l = RGBToHSL(uint8(r), uint8(g), uint8(b))
}
if tint < 0 {