engines/e_ossltest.c:629: error: NULL_DEREFERENCE
  pointer `tmpbuf` last assigned on line 622 could be null and is dereferenced by call to `memcpy()` at line 629, column 5.
Showing all 11 steps of the trace


engines/e_ossltest.c:619:1: start of procedure ossltest_aes128_gcm_cipher()
617.   
618.   
619. > int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
620.                                  const unsigned char *in, size_t inl)
621.   {

engines/e_ossltest.c:622:5: 
620.                                  const unsigned char *in, size_t inl)
621.   {
622. >     unsigned char *tmpbuf = OPENSSL_malloc(inl);
623.   
624.       /* OPENSSL_malloc will return NULL if inl == 0 */

crypto/mem.c:169:1: start of procedure CRYPTO_malloc()
  167.   #endif
  168.   
  169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171.       void *ret = NULL;

crypto/mem.c:171:5: 
  169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171. >     void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking true branch
  171.       void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  174.           return malloc_impl(num, file, line);
  175.   

crypto/mem.c:173:32: Taking true branch
  171.       void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  174.           return malloc_impl(num, file, line);
  175.   

crypto/mem.c:174:9: Skipping __function_pointer__(): unresolved function pointer
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  174.           return malloc_impl(num, file, line);
                 ^
  175.   
  176.       if (num == 0)

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
  193.   
  194.       return ret;
  195. > }
  196.   
  197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

engines/e_ossltest.c:625:9: Taking true branch
623.   
624.       /* OPENSSL_malloc will return NULL if inl == 0 */
625.       if (tmpbuf == NULL && inl > 0)
               ^
626.           return -1;
627.   

engines/e_ossltest.c:625:27: Taking false branch
623.   
624.       /* OPENSSL_malloc will return NULL if inl == 0 */
625.       if (tmpbuf == NULL && inl > 0)
                                 ^
626.           return -1;
627.   

engines/e_ossltest.c:629:5: 
627.   
628.       /* Remember what we were asked to encrypt */
629. >     memcpy(tmpbuf, in, inl);
630.   
631.       /* Go through the motions of encrypting it */

int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
                               const unsigned char *in, size_t inl)
{
    unsigned char *tmpbuf = OPENSSL_malloc(inl);
    if (tmpbuf == NULL && inl > 0)
        return -1;
    memcpy(tmpbuf, in, inl);
    EVP_CIPHER_meth_get_do_cipher(EVP_aes_128_gcm())(ctx, out, in, inl);
    memcpy(out, tmpbuf, inl);
    OPENSSL_free(tmpbuf);
    return inl;
}
['int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                               const unsigned char *in, size_t inl)\n{\n    unsigned char *tmpbuf = OPENSSL_malloc(inl);\n    if (tmpbuf == NULL && inl > 0)\n        return -1;\n    memcpy(tmpbuf, in, inl);\n    EVP_CIPHER_meth_get_do_cipher(EVP_aes_128_gcm())(ctx, out, in, inl);\n    memcpy(out, tmpbuf, inl);\n    OPENSSL_free(tmpbuf);\n    return inl;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']