gost-engine / engine

A reference implementation of the Russian GOST crypto algorithms for OpenSSL
Apache License 2.0
379 stars 174 forks source link

Fix static analysis (Infer) complains #462

Open yanovich opened 4 months ago

yanovich commented 4 months ago

Infer выдаёт четыре замечания к коду, все несущественные, три точно ложно положительные. На случай, если будет желание включить статический анализ в тесты, я все четыре починил.

$ infer run --compilation-database build/compile_commands.json
Capturing using compilation database...
Starting translating 53 files
53/53 [##############################################################################] 100% 5.34s

Found 53 source files to analyze in /home/s/src/crypto/engine/infer-out
Skipped large procedure (__infer_globals_initializer_grasshopper_pil_enc128, size:65543) in pulse.
Skipped large procedure (__infer_globals_initializer_grasshopper_pil_dec128, size:65543) in pulse.
Skipped large procedure (__infer_globals_initializer_grasshopper_l_dec128, size:65543) in pulse.
1161/1161 [##########################################################################] 100% 15.5s

gost12sum.c:253: error: Dead Store
  The value written to `&ptr` is never used. 
  251. {
  252.     int i, len;
  253.     char *ptr = filename;
           ^
  254.     char *spacepos = NULL;
  255. 

test_digest.c:662: error: Dead Store
  The value written to `&p` is never used. 
  660.     if (t->truncate) {
  661.         outsize = t->truncate;
  662.  *p++ = OSSL_PARAM_construct_size_t("size", &outsize);
         ^
  663.     }
  664.     else

test_tls.c:172: error: Uninitialized Value
  `_.cert` is read without initialization. 
  170. 
  171.     T(sctx = SSL_CTX_new(TLS_server_method()));
  172.     T(SSL_CTX_use_certificate(sctx, ck.cert));
           ^
  173.     T(SSL_CTX_use_PrivateKey(sctx, ck.pkey));
  174.     T(SSL_CTX_check_private_key(sctx));

test_tls.c:173: error: Uninitialized Value
  `_.pkey` is read without initialization. 
  171.     T(sctx = SSL_CTX_new(TLS_server_method()));
  172.     T(SSL_CTX_use_certificate(sctx, ck.cert));
  173.     T(SSL_CTX_use_PrivateKey(sctx, ck.pkey));
           ^
  174.     T(SSL_CTX_check_private_key(sctx));
  175. 

Found 4 issues
                      Issue Type(ISSUED_TYPE_ID): #
  Uninitialized Value(PULSE_UNINITIALIZED_VALUE): 2
                          Dead Store(DEAD_STORE): 2