]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Fix false positive static analysis issue
authorSergei Ianovich <sergei.ianovich@ya.ru>
Tue, 30 Jul 2024 14:33:18 +0000 (14:33 +0000)
committerSergei Ianovich <sergei.ianovich@ya.ru>
Tue, 30 Jul 2024 14:33:18 +0000 (14:33 +0000)
Infer complains:
```
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.
```

Altough the complain is false positive, fixing it will allow for future
use of the tools in automated tests.

test_tls.c

index 77e62815826d98039e6fdcb38a2ad31b5df0f885..72a8e081db221d4792bae9f67c3803e85954c69d 100644 (file)
@@ -78,7 +78,7 @@ static void err(int eval, const char *fmt, ...)
 }
 
 /* Generate simple cert+key pair. Based on req.c */
-static struct certkey certgen(const char *algname, const char *paramset)
+static void certgen(const char *algname, const char *paramset, struct certkey *ck)
 {
     /* Keygen. */
     EVP_PKEY *tkey;
@@ -150,7 +150,8 @@ static struct certkey certgen(const char *algname, const char *paramset)
     PEM_write_bio_X509(out, x509ss);
     BIO_free_all(out);
 #endif
-    return (struct certkey){ .pkey = pkey, .cert = x509ss };
+    ck->pkey = pkey;
+    ck->cert = x509ss;
 }
 
 /* Non-blocking BIO test mechanic is based on sslapitest.c */
@@ -164,7 +165,7 @@ int test(const char *algname, const char *paramset)
     printf(cNORM "\n");
 
     struct certkey ck;
-    ck = certgen(algname, paramset);
+    certgen(algname, paramset, &ck);
 
     SSL_CTX *cctx, *sctx;