Skip to content

Missing Error Check in function SSL_new() #4293

@lc3412

Description

@lc3412

Function SSL_new() returns NULL if the creation of a new SSL structure failed. However , the return value of function SSL_new() is not checked. See the following code:

line : 1189

connections[cnum].ssl = SSL_new(ssl_ctx);
SSL_set_fd(connections[cnum].ssl, connections[cnum].conn_fd);
r = SSL_connect(connections[cnum].ssl);
if (r <= 0) {
(void)fprintf(stderr, "%s: SSL connection failed - %d\n", argv0, r);
ERR_print_errors_fp(stderr);
close_connection(cnum);
return;
}

===============================================================================

We find the return value of this call been checked in openssl project with the version of openssl 1.1.2.
Such as in openssl/apps folder

line : 206
Ref : https://github.com/openssl/openssl/blob/0db957dbbcf6a432086ab913378c23636d8c374c/apps/ciphers.c#L206-L208

line 206:    ssl = SSL_new(ctx);
line 207:    if (ssl == NULL)
line 208:       goto err;

Chi Li, Zuxing Gu, Jiecheng Wu

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions