apps/s_server.c:644: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 643 could be null and is dereferenced by call to `X509_get1_ocsp()` at line 644, column 11.
Showing all 33 steps of the trace


apps/s_server.c:622:1: start of procedure cert_status_cb()
620.    */
621.   
622. > static int cert_status_cb(SSL *s, void *arg)
623.   {
624.       tlsextstatusctx *srctx = arg;

apps/s_server.c:624:5: 
622.   static int cert_status_cb(SSL *s, void *arg)
623.   {
624. >     tlsextstatusctx *srctx = arg;
625.       char *host = NULL, *port = NULL, *path = NULL;
626.       int use_ssl;

apps/s_server.c:625:5: 
623.   {
624.       tlsextstatusctx *srctx = arg;
625. >     char *host = NULL, *port = NULL, *path = NULL;
626.       int use_ssl;
627.       unsigned char *rspder = NULL;

apps/s_server.c:627:5: 
625.       char *host = NULL, *port = NULL, *path = NULL;
626.       int use_ssl;
627. >     unsigned char *rspder = NULL;
628.       int rspderlen;
629.       STACK_OF(OPENSSL_STRING) *aia = NULL;

apps/s_server.c:629:5: 
627.       unsigned char *rspder = NULL;
628.       int rspderlen;
629. >     STACK_OF(OPENSSL_STRING) *aia = NULL;
630.       X509 *x = NULL;
631.       X509_STORE_CTX inctx;

apps/s_server.c:630:5: 
628.       int rspderlen;
629.       STACK_OF(OPENSSL_STRING) *aia = NULL;
630. >     X509 *x = NULL;
631.       X509_STORE_CTX inctx;
632.       X509_OBJECT obj;

apps/s_server.c:633:5: 
631.       X509_STORE_CTX inctx;
632.       X509_OBJECT obj;
633. >     OCSP_REQUEST *req = NULL;
634.       OCSP_RESPONSE *resp = NULL;
635.       OCSP_CERTID *id = NULL;

apps/s_server.c:634:5: 
632.       X509_OBJECT obj;
633.       OCSP_REQUEST *req = NULL;
634. >     OCSP_RESPONSE *resp = NULL;
635.       OCSP_CERTID *id = NULL;
636.       STACK_OF(X509_EXTENSION) *exts;

apps/s_server.c:635:5: 
633.       OCSP_REQUEST *req = NULL;
634.       OCSP_RESPONSE *resp = NULL;
635. >     OCSP_CERTID *id = NULL;
636.       STACK_OF(X509_EXTENSION) *exts;
637.       int ret = SSL_TLSEXT_ERR_NOACK;

apps/s_server.c:637:5: 
635.       OCSP_CERTID *id = NULL;
636.       STACK_OF(X509_EXTENSION) *exts;
637. >     int ret = SSL_TLSEXT_ERR_NOACK;
638.       int i;
639.   

apps/s_server.c:640:9: Taking true branch
638.       int i;
639.   
640.       if (srctx->verbose)
               ^
641.           BIO_puts(bio_err, "cert_status: callback called\n");
642.       /* Build up OCSP query from server certificate */

apps/s_server.c:641:9: 
639.   
640.       if (srctx->verbose)
641. >         BIO_puts(bio_err, "cert_status: callback called\n");
642.       /* Build up OCSP query from server certificate */
643.       x = SSL_get_certificate(s);

crypto/bio/bio_lib.c:244:1: start of procedure BIO_puts()
  242.   }
  243.   
  244. > int BIO_puts(BIO *b, const char *in)
  245.   {
  246.       int i;

crypto/bio/bio_lib.c:249:10: Taking false branch
  247.       long (*cb) (BIO *, int, const char *, int, long, long);
  248.   
  249.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                  ^
  250.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  251.           return (-2);

crypto/bio/bio_lib.c:249:25: Taking false branch
  247.       long (*cb) (BIO *, int, const char *, int, long, long);
  248.   
  249.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                 ^
  250.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  251.           return (-2);

crypto/bio/bio_lib.c:249:48: Taking false branch
  247.       long (*cb) (BIO *, int, const char *, int, long, long);
  248.   
  249.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                                        ^
  250.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  251.           return (-2);

crypto/bio/bio_lib.c:254:5: 
  252.       }
  253.   
  254. >     cb = b->callback;
  255.   
  256.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))

crypto/bio/bio_lib.c:256:10: Taking false branch
  254.       cb = b->callback;
  255.   
  256.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
                  ^
  257.           return (i);
  258.   

crypto/bio/bio_lib.c:259:10: Taking true branch
  257.           return (i);
  258.   
  259.       if (!b->init) {
                  ^
  260.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
  261.           return (-2);

crypto/bio/bio_lib.c:260:9: Skipping ERR_put_error(): empty list of specs
  258.   
  259.       if (!b->init) {
  260.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
                 ^
  261.           return (-2);
  262.       }

crypto/bio/bio_lib.c:261:9: 
  259.       if (!b->init) {
  260.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
  261. >         return (-2);
  262.       }
  263.   

crypto/bio/bio_lib.c:272:1: return from a call to BIO_puts
  270.           i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
  271.       return (i);
  272. > }
  273.   
  274.   int BIO_gets(BIO *b, char *in, int inl)

apps/s_server.c:643:5: 
641.           BIO_puts(bio_err, "cert_status: callback called\n");
642.       /* Build up OCSP query from server certificate */
643. >     x = SSL_get_certificate(s);
644.       aia = X509_get1_ocsp(x);
645.       if (aia) {

ssl/ssl_lib.c:3099:1: start of procedure SSL_get_certificate()
  3097.   }
  3098.   
  3099. > X509 *SSL_get_certificate(const SSL *s)
  3100.   {
  3101.       if (s->cert != NULL)

ssl/ssl_lib.c:3101:9: Taking false branch
  3099.   X509 *SSL_get_certificate(const SSL *s)
  3100.   {
  3101.       if (s->cert != NULL)
                  ^
  3102.           return (s->cert->key->x509);
  3103.       else

ssl/ssl_lib.c:3104:9: 
  3102.           return (s->cert->key->x509);
  3103.       else
  3104. >         return (NULL);
  3105.   }
  3106.   

ssl/ssl_lib.c:3105:1: return from a call to SSL_get_certificate
  3103.       else
  3104.           return (NULL);
  3105. > }
  3106.   
  3107.   EVP_PKEY *SSL_get_privatekey(const SSL *s)

apps/s_server.c:644:5: 
642.       /* Build up OCSP query from server certificate */
643.       x = SSL_get_certificate(s);
644. >     aia = X509_get1_ocsp(x);
645.       if (aia) {
646.           if (!OCSP_parse_url(sk_OPENSSL_STRING_value(aia, 0),

crypto/x509v3/v3_utl.c:534:1: start of procedure X509_get1_ocsp()
  532.   }
  533.   
  534. > STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x)
  535.   {
  536.       AUTHORITY_INFO_ACCESS *info;

crypto/x509v3/v3_utl.c:537:5: 
  535.   {
  536.       AUTHORITY_INFO_ACCESS *info;
  537. >     STACK_OF(OPENSSL_STRING) *ret = NULL;
  538.       int i;
  539.   

crypto/x509v3/v3_utl.c:540:5: 
  538.       int i;
  539.   
  540. >     info = X509_get_ext_d2i(x, NID_info_access, NULL, NULL);
  541.       if (!info)
  542.           return NULL;

crypto/x509/x509_ext.c:150:1: start of procedure X509_get_ext_d2i()
    148.   }
    149.   
    150. > void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
    151.   {
    152.       return X509V3_get_d2i(x->cert_info.extensions, nid, crit, idx);

crypto/x509/x509_ext.c:152:5: 
    150.   void *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
    151.   {
    152. >     return X509V3_get_d2i(x->cert_info.extensions, nid, crit, idx);
    153.   }
    154.   
