Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible leaks in examples/echo #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Jun 17, 2021

  1. examples/echo: do not leak an opened file when an error happens

    In both `echo_load_private_key` and `echo_load_public_key`, when
    `len > MAX_DH_KEY_LEN`, the opened file is not closed before the
    function returns.
    
    Fix this possible resource leak by opening the file after checking `len`.
    
    This bug was found using clang's static analyzer:
    
        scan-build -enable-checker alpha.unix.Stream make
    niooss-ledger committed Jun 17, 2021
    Configuration menu
    Copy the full SHA
    1758c27 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2021

  1. examples/echo: free allocated memory when an error happens

    If either `priv_key` or `pub_key` is `NULL` but not the other one, the
    allocated memory is not freed. This issue is reported by clang's static
    analyzer.
    
    Fix this by calling `noise_free` in the error block.
    niooss-ledger committed Jul 2, 2021
    Configuration menu
    Copy the full SHA
    6cde834 View commit details
    Browse the repository at this point in the history