apps/openssl.c:112: error: NULL_DEREFERENCE
  pointer `p` last assigned on line 111 could be null and is dereferenced by call to `strcpy()` at line 112, column 5.
Showing all 25 steps of the trace


apps/openssl.c:100:1: start of procedure make_config_name()
98.   }
99.   
100. > static char *make_config_name(void)
101.   {
102.       const char *t;

apps/openssl.c:106:9: Taking false branch
104.       char *p;
105.   
106.       if ((t = getenv("OPENSSL_CONF")) != NULL)
               ^
107.           return OPENSSL_strdup(t);
108.   

apps/openssl.c:109:5: 
107.           return OPENSSL_strdup(t);
108.   
109. >     t = X509_get_default_cert_area();
110.       len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
111.       p = app_malloc(len, "config filename buffer");

crypto/x509/x509_def.c:20:1: start of procedure X509_get_default_cert_area()
  18.   }
  19.   
  20. > const char *X509_get_default_cert_area(void)
  21.   {
  22.       return X509_CERT_AREA;

crypto/x509/x509_def.c:22:5: 
  20.   const char *X509_get_default_cert_area(void)
  21.   {
  22. >     return X509_CERT_AREA;
  23.   }
  24.   

crypto/x509/x509_def.c:23:1: return from a call to X509_get_default_cert_area
  21.   {
  22.       return X509_CERT_AREA;
  23. > }
  24.   
  25.   const char *X509_get_default_cert_dir(void)

apps/openssl.c:110:5: 
108.   
109.       t = X509_get_default_cert_area();
110. >     len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
111.       p = app_malloc(len, "config filename buffer");
112.       strcpy(p, t);

apps/openssl.c:111:5: 
109.       t = X509_get_default_cert_area();
110.       len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
111. >     p = app_malloc(len, "config filename buffer");
112.       strcpy(p, t);
113.   #ifndef OPENSSL_SYS_VMS

test/testutil/apps_mem.c:14:1: start of procedure app_malloc()
  12.   /* shim that avoids sucking in too much from apps/apps.c */
  13.   
  14. > void* app_malloc(int sz, const char *what)
  15.   {
  16.       void *vp = OPENSSL_malloc(sz);

test/testutil/apps_mem.c:16:5: 
  14.   void* app_malloc(int sz, const char *what)
  15.   {
  16. >     void *vp = OPENSSL_malloc(sz);
  17.   
  18.       return vp;

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking true branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:197:32: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                          ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking true branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
    208.            * allocation.
    209.            */
    210. >         allow_customize = 0;
    211.       }
    212.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/testutil/apps_mem.c:18:5: 
  16.       void *vp = OPENSSL_malloc(sz);
  17.   
  18. >     return vp;
  19.   }

test/testutil/apps_mem.c:19:1: return from a call to app_malloc
  17.   
  18.       return vp;
  19. > }

apps/openssl.c:112:5: 
110.       len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
111.       p = app_malloc(len, "config filename buffer");
112. >     strcpy(p, t);
113.   #ifndef OPENSSL_SYS_VMS
114.       strcat(p, "/");

static char *make_config_name(void)
{
    const char *t;
    size_t len;
    char *p;
    if ((t = getenv("OPENSSL_CONF")) != NULL)
        return OPENSSL_strdup(t);
    t = X509_get_default_cert_area();
    len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
    p = app_malloc(len, "config filename buffer");
    strcpy(p, t);
#ifndef OPENSSL_SYS_VMS
    strcat(p, "/");
#endif
    strcat(p, OPENSSL_CONF);
    return p;
}
['static char *make_config_name(void)\n{\n    const char *t;\n    size_t len;\n    char *p;\n    if ((t = getenv("OPENSSL_CONF")) != NULL)\n        return OPENSSL_strdup(t);\n    t = X509_get_default_cert_area();\n    len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;\n    p = app_malloc(len, "config filename buffer");\n    strcpy(p, t);\n#ifndef OPENSSL_SYS_VMS\n    strcat(p, "/");\n#endif\n    strcat(p, OPENSSL_CONF);\n    return p;\n}', 'const char *X509_get_default_cert_area(void)\n{\n    return X509_CERT_AREA;\n}', 'void* app_malloc(int sz, const char *what)\n{\n    void *vp = OPENSSL_malloc(sz);\n    return vp;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']