aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-08-30 20:35:43 +0800
committerGitHub <noreply@github.com>2019-08-30 20:35:43 +0800
commitd5bd38384c1c0630d77468c12c8ad99d57ac2229 (patch)
treecbd46dbc3001fedecf46fe647d3ecbf0e9f92df8
parent396f1dd87b91cc08a1db08aaa2b901a47b69d26f (diff)
parent292cf7c649c4fa6cc63ed6a1ae9368d1dc70588d (diff)
downloadgo-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.tar
go-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.tar.gz
go-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.tar.bz2
go-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.tar.lz
go-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.tar.xz
go-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.tar.zst
go-tangerine-d5bd38384c1c0630d77468c12c8ad99d57ac2229.zip
Merge pull request #20019 from holiman/minor_adminfix
eth: disallow overwrite files via admin.exportChain
-rw-r--r--eth/api.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/eth/api.go b/eth/api.go
index 98c2f5874..f8c51c09b 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -168,6 +168,11 @@ func NewPrivateAdminAPI(eth *Ethereum) *PrivateAdminAPI {
// ExportChain exports the current blockchain into a local file.
func (api *PrivateAdminAPI) ExportChain(file string) (bool, error) {
+ if _, err := os.Stat(file); err == nil {
+ // File already exists. Allowing overwrite could be a DoS vecotor,
+ // since the 'file' may point to arbitrary paths on the drive
+ return false, errors.New("location would overwrite an existing file")
+ }
// Make sure we can create the file to export into
out, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil {