Skip to content

Commit

Permalink
Merge pull request ethereum#20019 from holiman/minor_adminfix
Browse files Browse the repository at this point in the history
eth: disallow overwrite files via admin.exportChain
  • Loading branch information
karalabe authored Aug 30, 2019
2 parents 396f1dd + 292cf7c commit d5bd383
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d5bd383

Please sign in to comment.