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 deref after null #17293
Fix deref after null #17293
Conversation
ctx may be NULL at 178 line CLA: trivial
209aee6
to
9c62261
Compare
file_close(ctx); | ||
if (ctx != NULL) | ||
file_close(ctx); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is actually no point in calling file_close(ctx) here. Just call free_file_ctx(ctx)
which works with NULL argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (loaderctx == NULL) | ||
assert(0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we want such assert calls. Please drop this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am OK with CLA: trivial
@@ -190,7 +190,7 @@ static void *file_open_dir(const char *path, const char *uri, void *provctx) | |||
} | |||
return ctx; | |||
err: | |||
file_close(ctx); | |||
free_file_ctx(ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really the correct behaviour? We can end up here if OPENSSL_DIR_read
returns a NULL value and errno != 0. If that occurs but OPENSSL_DIR_read
still populated ctx->_.dir.ctx
then file_close
still seems like the correct thing to do. Looking at LPdir_unix.c it seems that this could actually happen if the readdir call here returns NULL:
Lines 129 to 132 in dd2fcc1
direntry = readdir((*ctx)->dir); | |
if (direntry == NULL) { | |
return 0; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return file_close back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the correct fix is to just return NULL instead of the first goto err;
in the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Need some time. Do my way home.
@t8m Sorry for that long delay. Can you verify it once more :) Done my best this time :) |
LGTM |
@t8m Should I need to set "Resolved" all outdated code discussions or you'll done it by yourself? |
No need for that. |
I agree this is trivial |
24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually. |
Merged to master and 3.0. Thanks for the fix. |
ctx may be NULL at 178 line CLA: trivial Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from #17293)
ctx may be NULL at 178 line