Skip to content

Incorrect Error Check in function SSL_write() #4294

Closed

Description

@lc3412

Hi,
Function SSL_write() returns the value of 0 and less than 0 are both on error. However , the return value of function SSL_write() is not checked correctly, which forgot to check the return value 0. See the following code:

line : 1098, 1101

if (urls[url_num].protocol == PROTO_HTTPS)
r = SSL_write(connections[cnum].ssl, urls[url_num].buf, urls[url_num].buf_bytes);
else
r = write(connections[cnum].conn_fd, urls[url_num].buf, urls[url_num].buf_bytes);
if (r < 0) {
perror(urls[url_num].url_str);
connections[cnum].reusable = 0;
close_connection(cnum);
return;
}

The same situation is also occured on line 1216, 1219

if (urls[url_num].protocol == PROTO_HTTPS)
r = SSL_write(connections[cnum].ssl, urls[url_num].buf, urls[url_num].buf_bytes);
else
r = write(connections[cnum].conn_fd, urls[url_num].buf, urls[url_num].buf_bytes);
if (r < 0) {
perror(urls[url_num].url_str);
connections[cnum].reusable = 0;
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

Ref : https://github.com/openssl/openssl/blob/0db957dbbcf6a432086ab913378c23636d8c374c/apps/s_time.c#L231-L232

line 231:     if (buf_len <= 0 || SSL_write(scon, buf, buf_len) <= 0)
line 232:         goto end;

Chi Li, Zuxing Gu, Jiecheng Wu

Activity

  1. bryancall commented on May 30, 2019

    @bryancall
    Contributor

    Relates to #4293

  2. bryancall commented on May 30, 2019

    @bryancall
    Contributor

    @lc3412 Can you please make a PR for this?

  3. added this to the 9.0.0 milestone on May 30, 2019
  4. modified the milestones: 9.0.0, 10.0.0 on Aug 21, 2019
  5. added a commit that references this issue on Oct 29, 2019
  6. added a commit that references this issue on Nov 4, 2019
  7. added a commit that references this issue on Nov 4, 2019
  8. modified the milestones: 10.0.0, 9.0.0 on Nov 4, 2019
  9. added a commit that references this issue on Nov 19, 2019
  10. added a commit that references this issue on Nov 22, 2019
  11. added a commit that references this issue on Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions