Re: initialize variables patch for bn_nist.c
Brent Cook wrote: > I didn't notice it at first, because the patch wasn't inline, but the union > here needed to be initialized with memset or use a different kind of > initializer. > > I went with the memset on top of your patch: > > --- bn_nist.c 17 Jul 2016 21:21:40 - 1.16 > +++ bn_nist.c 17 Jul 2016 22:00:45 - > @@ -59,6 +59,7 @@ > #include > > #include > +#include > > #include "bn_lcl.h" > > @@ -568,7 +569,8 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM > BN_ULONG bn[BN_NIST_224_TOP]; > unsigned int ui[BN_NIST_224_TOP * > sizeof(BN_ULONG) / sizeof(unsigned int)]; > - } buf = {0}; > + } buf; > + memset(&buf, 0, sizeof(buf)); > BN_ULONG c_d[BN_NIST_224_TOP], *res; ok, but please don't mix code and decls like that.
Re: initialize variables patch for bn_nist.c
I didn't notice it at first, because the patch wasn't inline, but the union here needed to be initialized with memset or use a different kind of initializer. I went with the memset on top of your patch: --- bn_nist.c 17 Jul 2016 21:21:40 - 1.16 +++ bn_nist.c 17 Jul 2016 22:00:45 - @@ -59,6 +59,7 @@ #include #include +#include #include "bn_lcl.h" @@ -568,7 +569,8 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM BN_ULONG bn[BN_NIST_224_TOP]; unsigned int ui[BN_NIST_224_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; - } buf = {0}; + } buf; + memset(&buf, 0, sizeof(buf)); BN_ULONG c_d[BN_NIST_224_TOP], *res; uintptr_t mask; union { On Thu, Jul 14, 2016 at 8:39 AM, Bob Beck wrote: > I'm ok with this. > > > On Thu, Jul 14, 2016 at 4:57 AM, Kinichiro Inoguchi < > kinichiro.inogu...@gmail.com> wrote: > > > Hi, > > > > When I build LibreSSL portable on HP-UX 11.3 with HP C/aC++ compiler, > > this warning is detected. > > > > ... > > "bn/bn_nist.c", line 611: warning #2549-D: variable "buf" is used before > > its value is set > > nist_set_224(buf.bn, c_d, 14, 13, 12, 11, 10, 9, 8); > > ^ > > ... > > > > To initialize these variables before using, I would like to apply the > > patch. > > OK ? > > > > Here is original topic on GitHub. > > https://github.com/libressl-portable/openbsd/pull/19 > > > > Best Regards, > > > > kinichiro inoguchi > > > > >
Re: initialize variables patch for bn_nist.c
I'm ok with this. On Thu, Jul 14, 2016 at 4:57 AM, Kinichiro Inoguchi < kinichiro.inogu...@gmail.com> wrote: > Hi, > > When I build LibreSSL portable on HP-UX 11.3 with HP C/aC++ compiler, > this warning is detected. > > ... > "bn/bn_nist.c", line 611: warning #2549-D: variable "buf" is used before > its value is set > nist_set_224(buf.bn, c_d, 14, 13, 12, 11, 10, 9, 8); > ^ > ... > > To initialize these variables before using, I would like to apply the > patch. > OK ? > > Here is original topic on GitHub. > https://github.com/libressl-portable/openbsd/pull/19 > > Best Regards, > > kinichiro inoguchi > >
initialize variables patch for bn_nist.c
Hi, When I build LibreSSL portable on HP-UX 11.3 with HP C/aC++ compiler, this warning is detected. ... "bn/bn_nist.c", line 611: warning #2549-D: variable "buf" is used before its value is set nist_set_224(buf.bn, c_d, 14, 13, 12, 11, 10, 9, 8); ^ ... To initialize these variables before using, I would like to apply the patch. OK ? Here is original topic on GitHub. https://github.com/libressl-portable/openbsd/pull/19 Best Regards, kinichiro inoguchi diff --git src/lib/libssl/src/crypto/bn/bn_nist.c src/lib/libssl/src/crypto/bn/bn_nist.c index 4d3a612..a87309b 100644 --- src/lib/libssl/src/crypto/bn/bn_nist.c +++ src/lib/libssl/src/crypto/bn/bn_nist.c @@ -510,7 +510,7 @@ BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) } #else { - BN_ULONG t_d[BN_NIST_192_TOP]; + BN_ULONG t_d[BN_NIST_192_TOP] = {0}; nist_set_192(t_d, buf.bn, 0, 3, 3); carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP); @@ -568,7 +568,7 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) BN_ULONG bn[BN_NIST_224_TOP]; unsigned int ui[BN_NIST_224_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; - } buf; + } buf = {0}; BN_ULONG c_d[BN_NIST_224_TOP], *res; uintptr_t mask; union { @@ -673,7 +673,7 @@ BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) } #else { - BN_ULONG t_d[BN_NIST_224_TOP]; + BN_ULONG t_d[BN_NIST_224_TOP] = {0}; nist_set_224(t_d, buf.bn, 10, 9, 8, 7, 0, 0, 0); carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP); @@ -746,7 +746,7 @@ BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) unsigned int ui[BN_NIST_256_TOP * sizeof(BN_ULONG) / sizeof(unsigned int)]; } buf; - BN_ULONG c_d[BN_NIST_256_TOP], *res; + BN_ULONG c_d[BN_NIST_256_TOP] = {0}, *res; uintptr_t mask; union { bn_addsub_f f; @@ -879,7 +879,7 @@ BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) } #else { - BN_ULONG t_d[BN_NIST_256_TOP]; + BN_ULONG t_d[BN_NIST_256_TOP] = {0}; /*S1*/ nist_set_256(t_d, buf.bn, 15, 14, 13, 12, 11, 0, 0, 0); @@ -1133,7 +1133,7 @@ BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, BN_CTX *ctx) } #else { - BN_ULONG t_d[BN_NIST_384_TOP]; + BN_ULONG t_d[BN_NIST_384_TOP] = {0}; /*S1*/ nist_set_256(t_d, buf.bn, 0, 0, 0, 0, 0, 23 - 4, 22 - 4,