Skip to content

BearSSLClient::write fails to send data buffer > 512 bytes #300

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

Closed
pennam opened this issue Jan 28, 2022 · 1 comment · Fixed by #337
Closed

BearSSLClient::write fails to send data buffer > 512 bytes #300

pennam opened this issue Jan 28, 2022 · 1 comment · Fixed by #337
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@pennam
Copy link
Collaborator

pennam commented Jan 28, 2022

Opened to track this issue arduino-libraries/ArduinoBearSSL#60 and related PR arduino-libraries/ArduinoBearSSL#61

@pennam pennam added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jan 28, 2022
@pennam pennam self-assigned this Jan 28, 2022
@Jeroen88
Copy link

The problem is here:

  • If more than 512 bytes are written, then result == 512. In the next 'while' round, size is still it's original value, which is incorrect. This is working:
size_t BearSSLClient::write(const uint8_t *buf, size_t size)
{
  size_t written = 0;
  size_t toWrite = size;

  while (written < toWrite) {
    int result = br_sslio_write(&_ioc, buf, size);

    if (result < 0) {
      break;
    }

    buf += result;
    written += result;
    size -= result;
  }

  if (written == toWrite && br_sslio_flush(&_ioc) < 0) {
    return 0;
  }

  return written;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants