-
Notifications
You must be signed in to change notification settings - Fork 834
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
Initialize vars & change types to appease Windows/VS #8181
base: master
Are you sure you want to change the base?
Conversation
7791535
to
028195d
Compare
2ad9df3
to
8e4cc38
Compare
Jenkins retest this please |
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.
Nice cleanups and extra checks. Passes my review and testing. Over to @SparkiDev to finalize.
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.
Mostly looks good! Had a few nits and a question or two.
src/bio.c
Outdated
if ((closeFlag != WOLFSSL_BIO_NOCLOSE ) && \ | ||
(closeFlag != WOLFSSL_BIO_CLOSE)) { | ||
return BAD_FUNC_ARG; | ||
} | ||
|
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.
This check duplicates the check right above it. The earlier check should be using the WOLFSSL_
version of the constants, so by all means fix that.
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.
Oh, that's an excellent catch! I removed that code, and edited the one above.
src/bio.c
Outdated
bio->mem_buf = bufMem; | ||
bio->shutdown = closeFlag; | ||
bio->shutdown = (byte)closeFlag; |
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.
bio->shutdown
is actually a single bit in a bitfield, so the right construction here is closeFlag ? 1 : 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.
What do you think of using these, instead?
bio->shutdown = closeFlag ? WOLFSSL_BIO_CLOSE : WOLFSSL_BIO_NOCLOSE
src/ssl_asn1.c
Outdated
SetImplicit(tmp[0], mem->tag, 0, imp, 0); | ||
/* Encode the implicit tag; There's other stuff in the upper bits | ||
* of the integer tag, so strip out everything else for value. */ | ||
SetImplicit(tmp[0], (byte)(mem->tag & ASN_IMPLICIT_TAG_MASK), |
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.
When you're explicitly casting to byte
, there is no reason to explicitly mask. The (byte)
always masks as needed.
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.
Indeed there's no need to explicitly mask, and I suppose with the new comments it's ok. But I generally prefer code that's more intuitive to immediately understand. That's also why I spelled out the full size of 0x000000FF
and not just 0xFF
. Happy to change it if you prefer otherwise.
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 would prefer the masking removed and it suggests that not all of the bottom 8 bits will be used. We want it all.
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.
ok, @SparkiDev - masking macro removed.
src/ssl_asn1.c
Outdated
#define ASN_IMPLICIT_TAG_MASK 0x000000FF | ||
|
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.
Not needed -- see below.
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.
Intentional, but open to change - particularly since known non-zero data gets truncated.
src/tls13.c
Outdated
int sendSz; | ||
word16 extSz; | ||
word32 length; | ||
word32 idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; | ||
word16 idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; |
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.
Seems like the wrong idea to use word16
for idx
-- makes it more vulnerable to overflow. Though to be fair, there are currently no checks in the body of the function for overflow. Perhaps revert idx
to word32
, and add casts where necessary, immediately preceded by overflow tests?
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, yes. Good point. word32
for idx
. What would you use for an error code? Add something like this in here tls13.c?
if (idx > WOLFSSL_MAX_16BIT) {
return BAD_LENGTH_E;
}
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.
Although the prior change seemed happy with the VS/Windows build, today I was seeing the "conversion from 'word32' to 'word16', possible loss of data" error again today.
So in addition to removing the ASN_IMPLICIT_TAG_MASK
in ssl.asn1.c
, I've also added explicit (word16)
type casts to the 32-bit idx
in the tls13.c
file.
8e4cc38
to
2f04bf0
Compare
2f04bf0
to
5d86031
Compare
Description
Addresses these warnings encountered during a Windows / Visual Studio build:
#define WOLFSSL_MAX_8BIT 0xffU
intype.h
warning C4141: 'dllexport': used more than once
, noted above.Fixes zd# n/a
Testing
Confirmed working with benchmark and test apps.
Checklist