Skip to content

Commit

Permalink
Merge pull request #684 from srl-labs/filecopy-fix
Browse files Browse the repository at this point in the history
fixed nil deref in `CopyFile`
  • Loading branch information
hellt committed Nov 18, 2021
2 parents c5b890d + 5486915 commit 3d7c6bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion docs/rn/0.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ For example, here is our [NANOG83 talk](../community.md):
* Containerlab' config engine will not error on the nodes for which credentials were not found ([#675](https://github.com/srl-labs/containerlab/pull/675))
* SONiC boot will not block in case of failures ([#678](https://github.com/srl-labs/containerlab/pull/678))

## Patches

### 0.20.1
* Fix panic when copy files ([#684](https://github.com/srl-labs/containerlab/pull/684))

## New contributors
Welcome [@LimeHat](https://github.com/LimeHat) and thank you for your contributions to containerlab!
Welcome [@LimeHat](https://github.com/LimeHat), and thank you for your contributions to containerlab!
14 changes: 7 additions & 7 deletions utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func CopyFile(src, dst string, mode os.FileMode) (err error) {
if !os.IsNotExist(err) {
return err
}
}

if !(dfi.Mode().IsRegular()) {
return fmt.Errorf("CopyFile: non-regular destination file %s (%q)", dfi.Name(), dfi.Mode().String())
}
} else {
if !(dfi.Mode().IsRegular()) {
return fmt.Errorf("CopyFile: non-regular destination file %s (%q)", dfi.Name(), dfi.Mode().String())
}

if sfi != nil && os.SameFile(sfi, dfi) {
return
if sfi != nil && os.SameFile(sfi, dfi) {
return
}
}

return CopyFileContents(src, dst, mode)
Expand Down

0 comments on commit 3d7c6bc

Please sign in to comment.