Skip to content

Possible error in BEAR_SSL_CLIENT_IBUF_SIZE calculation #79

Closed
@imatrisciano

Description

@imatrisciano

In BearSSLClient.h line 40-45 the values for BEAR_SSL_CLIENT_OBUF_SIZE and BEAR_SSL_CLIENT_IBUF_SIZE are calculated.

#ifndef BEAR_SSL_CLIENT_OBUF_SIZE
#define BEAR_SSL_CLIENT_OBUF_SIZE 512 + 85
#endif
#ifndef BEAR_SSL_CLIENT_IBUF_SIZE
#define BEAR_SSL_CLIENT_IBUF_SIZE 8192 + 85 + 325 - BEAR_SSL_CLIENT_OBUF_SIZE
#endif

By writing so, BEAR_SSL_CLIENT_OBUF_SIZE will be computed to be 512+85 = 597.
I would expect BEAR_SSL_CLIENT_IBUF_SIZE to be 8192 + 85 + 325 - 597 = 8005
But by using defines the code for BEAR_SSL_CLIENT_IBUF_SIZE actually compiles to 8192 + 85 + 325 - 512 + 85 = 8175

I don't know if this is intended behaviour. If it's not, things can be fixed by just adding some parenthesis

#ifndef BEAR_SSL_CLIENT_OBUF_SIZE
#define BEAR_SSL_CLIENT_OBUF_SIZE (512 + 85)
#endif

#ifndef BEAR_SSL_CLIENT_IBUF_SIZE
#define BEAR_SSL_CLIENT_IBUF_SIZE (8192 + 85 + 325 - BEAR_SSL_CLIENT_OBUF_SIZE)
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions