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

New context object close()s old context’s debugout. #52

FGasper opened this issue Jul 31, 2019 · 2 comments

New context object close()s old context’s debugout. #52

FGasper opened this issue Jul 31, 2019 · 2 comments


Copy link

FGasper commented Jul 31, 2019

Related to #39

Copy link
Contributor Author

FGasper commented Jul 31, 2019

#include <stdio.h>
#include <unistd.h>
#include <unbound.h>

int main(void) {
    struct ub_ctx* ctx = ub_ctx_create();

    FILE *out_fh = fopen("./bug52-out", "w");
    if (!out_fh) {
        return 1;

    ub_ctx_debugout(ctx, out_fh);

    struct ub_ctx* ctx2 = ub_ctx_create();

    char str[] = "I am Iron Man!\n";

    if ( !fwrite(str, 1, sizeof(str), out_fh) ) {

        return 1;

    return 0;

On my system:

gcc -L/opt/local/lib -I/opt/local/include -lunbound bug52.c -o bug52

… and the error:

> ./bug52
fwrite: Bad file descriptor

Copy link

See the PR #53 comments, another commit to fix it. Let me know if that really fixes all the codepaths, apart from the reported. Thanks for the report!

jedisct1 added a commit to jedisct1/unbound that referenced this issue Aug 7, 2019
* nlnet/master:
  - Check repinfo in worker_handle_request, if null, drop it.
  - Fix to timeval_add for remaining second in microseconds.
  - Fix to return after failed auth zone http chunk write. - Fix to remove unused test for task_probe existance.
  - Fix NLnetLabs#52 NLnetLabs#53, fix for example fail program.
  - For NLnetLabs#52 NLnetLabs#53, second context does not close logfile override.
  Fix comment.
  - Add hex print of trust anchor pointer to trust anchor file temp   name to make it unique, for libunbound created multiple contexts.
  - Add verbose log message when auth zone file is written, at level 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants