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


apps/s_server.c:825:1: start of procedure cert_status_cb()
823.    */
824.   
825. > static int cert_status_cb(SSL *s, void *arg)
826.   {
827.       tlsextstatusctx *srctx = arg;

apps/s_server.c:827:5: 
825.   static int cert_status_cb(SSL *s, void *arg)
826.   {
827. >     tlsextstatusctx *srctx = arg;
828.       BIO *err = srctx->err;
829.       char *host, *port, *path;

apps/s_server.c:828:5: 
826.   {
827.       tlsextstatusctx *srctx = arg;
828. >     BIO *err = srctx->err;
829.       char *host, *port, *path;
830.       int use_ssl;

apps/s_server.c:831:5: 
829.       char *host, *port, *path;
830.       int use_ssl;
831. >     unsigned char *rspder = NULL;
832.       int rspderlen;
833.       STACK_OF(OPENSSL_STRING) *aia = NULL;

apps/s_server.c:833:5: 
831.       unsigned char *rspder = NULL;
832.       int rspderlen;
833. >     STACK_OF(OPENSSL_STRING) *aia = NULL;
834.       X509 *x = NULL;
835.       X509_STORE_CTX inctx;

apps/s_server.c:834:5: 
832.       int rspderlen;
833.       STACK_OF(OPENSSL_STRING) *aia = NULL;
834. >     X509 *x = NULL;
835.       X509_STORE_CTX inctx;
836.       X509_OBJECT obj;

apps/s_server.c:837:5: 
835.       X509_STORE_CTX inctx;
836.       X509_OBJECT obj;
837. >     OCSP_REQUEST *req = NULL;
838.       OCSP_RESPONSE *resp = NULL;
839.       OCSP_CERTID *id = NULL;

apps/s_server.c:838:5: 
836.       X509_OBJECT obj;
837.       OCSP_REQUEST *req = NULL;
838. >     OCSP_RESPONSE *resp = NULL;
839.       OCSP_CERTID *id = NULL;
840.       STACK_OF(X509_EXTENSION) *exts;

apps/s_server.c:839:5: 
837.       OCSP_REQUEST *req = NULL;
838.       OCSP_RESPONSE *resp = NULL;
839. >     OCSP_CERTID *id = NULL;
840.       STACK_OF(X509_EXTENSION) *exts;
841.       int ret = SSL_TLSEXT_ERR_NOACK;

apps/s_server.c:841:5: 
839.       OCSP_CERTID *id = NULL;
840.       STACK_OF(X509_EXTENSION) *exts;
841. >     int ret = SSL_TLSEXT_ERR_NOACK;
842.       int i;
843.       if (srctx->verbose)

apps/s_server.c:843:9: Taking true branch
841.       int ret = SSL_TLSEXT_ERR_NOACK;
842.       int i;
843.       if (srctx->verbose)
               ^
844.           BIO_puts(err, "cert_status: callback called\n");
845.       /* Build up OCSP query from server certificate */

apps/s_server.c:844:9: 
842.       int i;
843.       if (srctx->verbose)
844. >         BIO_puts(err, "cert_status: callback called\n");
845.       /* Build up OCSP query from server certificate */
846.       x = SSL_get_certificate(s);

crypto/bio/bio_lib.c:253:1: start of procedure BIO_puts()
  251.   }
  252.   
  253. > int BIO_puts(BIO *b, const char *in)
  254.   {
  255.       int i;

crypto/bio/bio_lib.c:258:10: Taking false branch
  256.       long (*cb) (BIO *, int, const char *, int, long, long);
  257.   
  258.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                  ^
  259.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  260.           return (-2);

crypto/bio/bio_lib.c:258:25: Taking false branch
  256.       long (*cb) (BIO *, int, const char *, int, long, long);
  257.   
  258.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                 ^
  259.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  260.           return (-2);

crypto/bio/bio_lib.c:258:48: Taking false branch
  256.       long (*cb) (BIO *, int, const char *, int, long, long);
  257.   
  258.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                                        ^
  259.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
  260.           return (-2);

crypto/bio/bio_lib.c:263:5: 
  261.       }
  262.   
  263. >     cb = b->callback;
  264.   
  265.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))

crypto/bio/bio_lib.c:265:10: Taking false branch
  263.       cb = b->callback;
  264.   
  265.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
                  ^
  266.           return (i);
  267.   

crypto/bio/bio_lib.c:268:10: Taking false branch
  266.           return (i);
  267.   
  268.       if (!b->init) {
                  ^
  269.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
  270.           return (-2);

crypto/bio/bio_lib.c:273:5: Skipping __function_pointer__(): unresolved function pointer
  271.       }
  272.   
  273.       i = b->method->bputs(b, in);
             ^
  274.   
  275.       if (i > 0)

crypto/bio/bio_lib.c:275:9: Taking true branch
  273.       i = b->method->bputs(b, in);
  274.   
  275.       if (i > 0)
                 ^
  276.           b->num_write += (unsigned long)i;
  277.   

crypto/bio/bio_lib.c:276:9: 
  274.   
  275.       if (i > 0)
  276. >         b->num_write += (unsigned long)i;
  277.   
  278.       if (cb != NULL)

crypto/bio/bio_lib.c:278:9: Taking false branch
  276.           b->num_write += (unsigned long)i;
  277.   
  278.       if (cb != NULL)
                 ^
  279.           i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
  280.       return (i);

crypto/bio/bio_lib.c:280:5: 
  278.       if (cb != NULL)
  279.           i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
  280. >     return (i);
  281.   }
  282.   

crypto/bio/bio_lib.c:281:1: return from a call to BIO_puts
  279.           i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
  280.       return (i);
  281. > }
  282.   
  283.   int BIO_gets(BIO *b, char *in, int inl)

apps/s_server.c:846:5: 
844.           BIO_puts(err, "cert_status: callback called\n");
845.       /* Build up OCSP query from server certificate */
846. >     x = SSL_get_certificate(s);
847.       aia = X509_get1_ocsp(x);
848.       if (aia) {

ssl/ssl_lib.c:2902:1: start of procedure SSL_get_certificate()
  2900.   }
  2901.   
  2902. > X509 *SSL_get_certificate(const SSL *s)
  2903.   {
  2904.       if (s->cert != NULL)

ssl/ssl_lib.c:2904:9: Taking false branch
  2902.   X509 *SSL_get_certificate(const SSL *s)
  2903.   {
  2904.       if (s->cert != NULL)
                  ^
  2905.           return (s->cert->key->x509);
  2906.       else

ssl/ssl_lib.c:2907:9: 
  2905.           return (s->cert->key->x509);
  2906.       else
  2907. >         return (NULL);
  2908.   }
  2909.   

ssl/ssl_lib.c:2908:1: return from a call to SSL_get_certificate
  2906.       else
  2907.           return (NULL);
  2908. > }
  2909.   
  2910.   EVP_PKEY *SSL_get_privatekey(const SSL *s)

apps/s_server.c:847:5: 
845.       /* Build up OCSP query from server certificate */
846.       x = SSL_get_certificate(s);
847. >     aia = X509_get1_ocsp(x);
848.       if (aia) {
849.           if (!OCSP_parse_url(sk_OPENSSL_STRING_value(aia, 0),
