summaryrefslogtreecommitdiff
path: root/lib.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-05-29 00:26:40 +0800
committerxuri <xuri.me@gmail.com>2020-05-29 00:26:40 +0800
commit2ae631376b95ff0a59ea18c2c0befcd50135b020 (patch)
treec3542c127aed38cac104c513047327d6316b91d1 /lib.go
parentc168233e70db8f220bd07d9d6d277ae9e2a4a73f (diff)
add limits for total columns, row and filename length
Diffstat (limited to 'lib.go')
-rw-r--r--lib.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib.go b/lib.go
index 91b3635..d97bb20 100644
--- a/lib.go
+++ b/lib.go
@@ -135,6 +135,9 @@ func ColumnNameToNumber(name string) (int, error) {
}
multi *= 26
}
+ if col > TotalColumns {
+ return -1, fmt.Errorf("column number exceeds maximum limit")
+ }
return col, nil
}
@@ -172,7 +175,9 @@ func CellNameToCoordinates(cell string) (int, int, error) {
if err != nil {
return -1, -1, fmt.Errorf(msg, cell, err)
}
-
+ if row > TotalRows {
+ return -1, -1, fmt.Errorf("row number exceeds maximum limit")
+ }
col, err := ColumnNameToNumber(colname)
return col, row, err
}