From 2ae631376b95ff0a59ea18c2c0befcd50135b020 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 29 May 2020 00:26:40 +0800 Subject: add limits for total columns, row and filename length --- lib.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib.go') 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 } -- cgit v1.2.1