On 2/5/2011 4:31 PM, Ludovic Rousseau wrote: > Hello, > > My compiler (gcc 4.2.1) complains with: > > piv-tool.c: In function ‘main’: > piv-tool.c:347: warning: ‘x’ is used uninitialized in this function > piv-tool.c:335: note: ‘x’ was declared here > piv-tool.c:348: warning: ‘y’ is used uninitialized in this function > piv-tool.c:336: note: ‘y’ was declared here > piv-tool.c:264: warning: ‘nid’ may be used uninitialized in this function > piv-tool.c:264: note: ‘nid’ was declared here > > > The code does: > BIGNUM *x; > BIGNUM *y; > > x = BN_bin2bn(keydata.ecpoint + 1, i, x); > y = BN_bin2bn(keydata.ecpoint + 1 + i, i, y) ; > > So x and y are used in BN_bin2bn with an undefined value. > According to bn_bin2bn manpage [1]: > BN_bin2bn() converts the positive integer in big-endian form of > length len at s into a BIGNUM and places it in ret. If ret is NULL, a > new BIGNUM is created. > > Maybe the code should be: > x = BN_bin2bn(keydata.ecpoint + 1, i, NULL); > y = BN_bin2bn(keydata.ecpoint + 1 + i, i, NULL) ;
Yes, that looks correct. I will commit a patch. > > > Also nid is not initialized in all cases. I don't know what default > value to use. It is only used in the card 0x11 and 0x14 which are the ECC cases. I will set it to -1 as the default. Thanks for looking at and fixing all the warning messages! > > Bye > > [1] http://www.openssl.org/docs/crypto/BN_bn2bin.html > -- Douglas E. Engert <deeng...@anl.gov> Argonne National Laboratory 9700 South Cass Avenue Argonne, Illinois 60439 (630) 252-5444 _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel