From 90b728ba4fdf80b5999fd3b452de39471fdf3e26 Mon Sep 17 00:00:00 2001 From: "lionel.ngo" Date: Thu, 27 Jan 2022 15:39:27 +0100 Subject: [PATCH] Remove config file size limit --- v1/config/file.go | 8 +++++++- v2/config/file.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/v1/config/file.go b/v1/config/file.go index d18622614..b106df6b6 100644 --- a/v1/config/file.go +++ b/v1/config/file.go @@ -49,8 +49,14 @@ func ReadFromFile(cnfPath string) ([]byte, error) { return nil, fmt.Errorf("Open file error: %s", err) } + fileInfo, err := file.Stat() + if err != nil { + return nil, fmt.Errorf("Get file info error: %s", err) + } + length := fileInfo.Size() + // Config file found, let's try to read it - data := make([]byte, 1000) + data := make([]byte, length) count, err := file.Read(data) if err != nil { return nil, fmt.Errorf("Read from file error: %s", err) diff --git a/v2/config/file.go b/v2/config/file.go index acc190348..0910b87ba 100644 --- a/v2/config/file.go +++ b/v2/config/file.go @@ -49,8 +49,14 @@ func ReadFromFile(cnfPath string) ([]byte, error) { return nil, fmt.Errorf("Open file error: %s", err) } + fileInfo, err := file.Stat() + if err != nil { + return nil, fmt.Errorf("Get file info error: %s", err) + } + length := fileInfo.Size() + // Config file found, let's try to read it - data := make([]byte, 1000) + data := make([]byte, length) count, err := file.Read(data) if err != nil { return nil, fmt.Errorf("Read from file error: %s", err)