JuliaLang / MbedTLS.jl

Wrapper around mbedtls
Other
41 stars 50 forks source link

Take out extra, unnecessary isopen checks #255

Closed quinnj closed 2 years ago

quinnj commented 2 years ago

We check Base.check_open, then iswritable checks isopen, and then we check isopen again in f_send before we actually write. None of this is particularly problematic except that if our bio isn't open in Base.check_open then we get an IOError, but if iswritable fails, we get an ArgumentError.

By delaying the isopen check until f_send, I believe that will result in a more predictable MbedException being thrown consistently.

I believe this was a source of the occasional unsafe_write requires iswritable(::SSLContext) error where it was actually just a data race between the first Base.check_open and the second isopen in iswritable.

codecov[bot] commented 2 years ago

Codecov Report

Merging #255 (97703b2) into master (22f5393) will decrease coverage by 0.31%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #255      +/-   ##
==========================================
- Coverage   74.06%   73.75%   -0.32%     
==========================================
  Files          12       12              
  Lines         721      720       -1     
==========================================
- Hits          534      531       -3     
- Misses        187      189       +2     
Impacted Files Coverage Δ
src/ssl.jl 72.60% <100.00%> (-0.10%) :arrow_down:
src/entropy.jl 80.76% <0.00%> (-3.85%) :arrow_down:
src/ctr_drbg.jl 81.48% <0.00%> (-3.71%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.