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


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

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

crypto/mem.c:157:1: start of procedure CRYPTO_malloc()
  155.   #endif
  156.   
  157. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  158.   {
  159.       void *ret = NULL;

crypto/mem.c:159:5: 
  157.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  158.   {
  159. >     void *ret = NULL;
  160.   
  161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:161:9: Taking true branch
  159.       void *ret = NULL;
  160.   
  161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  162.           return malloc_impl(num, file, line);
  163.   

crypto/mem.c:161:32: Taking true branch
  159.       void *ret = NULL;
  160.   
  161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  162.           return malloc_impl(num, file, line);
  163.   

crypto/mem.c:162:9: Skipping __function_pointer__(): unresolved function pointer
  160.   
  161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  162.           return malloc_impl(num, file, line);
                 ^
  163.   
  164.       if (num <= 0)

crypto/mem.c:183:1: return from a call to CRYPTO_malloc
  181.   
  182.       return ret;
  183. > }
  184.   
  185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

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

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

engines/e_ossltest.c:627:5: 
625.   
626.       /* Remember what we were asked to encrypt */
627. >     memcpy(tmpbuf, in, inl);
628.   
629.       /* 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}']