commit 3be4b5e2d3ba2add44e0d0307ad3f2487f8ad208
Author: David Fifield <[email protected]>
Date:   Tue Mar 5 16:14:35 2019 -0700

    Report a Close error in readAuthCookieFile.
    
    https://bugs.torproject.org/15826#comment:1
---
 pt.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/pt.go b/pt.go
index 95695ac..f7929e6 100644
--- a/pt.go
+++ b/pt.go
@@ -616,12 +616,17 @@ func readAuthCookie(f io.Reader) ([]byte, error) {
 
 // Read and validate the contents of an auth cookie file. Returns the 32-byte
 // cookie. See section 4.2.1.2 of 217-ext-orport-auth.txt.
-func readAuthCookieFile(filename string) ([]byte, error) {
+func readAuthCookieFile(filename string) (cookie []byte, err error) {
        f, err := os.Open(filename)
        if err != nil {
                return nil, err
        }
-       defer f.Close()
+       defer func() {
+               closeErr := f.Close()
+               if err == nil {
+                       err = closeErr
+               }
+       }()
 
        return readAuthCookie(f)
 }

_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to