test/dummytest.c:32: error: NULL_DEREFERENCE
  pointer `program` last assigned on line 31 could be null and is dereferenced by call to `strncpy()` at line 32, column 3.
Showing all 29 steps of the trace


test/dummytest.c:9:1: start of procedure main()
7.   #include <openssl/crypto.h>
8.   
9. > int main(int argc, char *argv[])
10.   	{
11.   	char *p, *q = 0, *program;

test/dummytest.c:11:2: 
9.   int main(int argc, char *argv[])
10.   	{
11. > 	char *p, *q = 0, *program;
12.   
13.   	p = strrchr(argv[0], '/');

test/dummytest.c:13:2: 
11.   	char *p, *q = 0, *program;
12.   
13. > 	p = strrchr(argv[0], '/');
14.   	if (!p) p = strrchr(argv[0], '\\');
15.   #ifdef OPENSSL_SYS_VMS

test/dummytest.c:14:7: Taking true branch
12.   
13.   	p = strrchr(argv[0], '/');
14.   	if (!p) p = strrchr(argv[0], '\\');
            ^
15.   #ifdef OPENSSL_SYS_VMS
16.   	if (!p) p = strrchr(argv[0], ']');

test/dummytest.c:14:10: 
12.   
13.   	p = strrchr(argv[0], '/');
14. > 	if (!p) p = strrchr(argv[0], '\\');
15.   #ifdef OPENSSL_SYS_VMS
16.   	if (!p) p = strrchr(argv[0], ']');

test/dummytest.c:22:6: Taking true branch
20.   	q = 0;
21.   #endif
22.   	if (p) p++;
           ^
23.   	if (!p) p = argv[0];
24.   	if (p) q = strchr(p, '.');

test/dummytest.c:22:9: 
20.   	q = 0;
21.   #endif
22. > 	if (p) p++;
23.   	if (!p) p = argv[0];
24.   	if (p) q = strchr(p, '.');

test/dummytest.c:23:7: Taking false branch
21.   #endif
22.   	if (p) p++;
23.   	if (!p) p = argv[0];
            ^
24.   	if (p) q = strchr(p, '.');
25.   	if (p && !q) q = p + strlen(p);

test/dummytest.c:24:6: Taking true branch
22.   	if (p) p++;
23.   	if (!p) p = argv[0];
24.   	if (p) q = strchr(p, '.');
           ^
25.   	if (p && !q) q = p + strlen(p);
26.   

test/dummytest.c:24:9: 
22.   	if (p) p++;
23.   	if (!p) p = argv[0];
24. > 	if (p) q = strchr(p, '.');
25.   	if (p && !q) q = p + strlen(p);
26.   

test/dummytest.c:25:6: Taking true branch
23.   	if (!p) p = argv[0];
24.   	if (p) q = strchr(p, '.');
25.   	if (p && !q) q = p + strlen(p);
           ^
26.   
27.   	if (!p)

test/dummytest.c:25:12: Taking true branch
23.   	if (!p) p = argv[0];
24.   	if (p) q = strchr(p, '.');
25.   	if (p && !q) q = p + strlen(p);
                 ^
26.   
27.   	if (!p)

test/dummytest.c:25:15: 
23.   	if (!p) p = argv[0];
24.   	if (p) q = strchr(p, '.');
25. > 	if (p && !q) q = p + strlen(p);
26.   
27.   	if (!p)

test/dummytest.c:27:7: Taking false branch
25.   	if (p && !q) q = p + strlen(p);
26.   
27.   	if (!p)
            ^
28.   		program = BUF_strdup("(unknown)");
29.   	else

test/dummytest.c:31:3: 
29.   	else
30.   		{
31. > 		program = OPENSSL_malloc((q - p) + 1);
32.   		strncpy(program, p, q - p);
33.   		program[q - p] = '\0';

crypto/mem.c:291:1: start of procedure CRYPTO_malloc()
  289.   	}
  290.   
  291. > void *CRYPTO_malloc(int num, const char *file, int line)
  292.   	{
  293.   	void *ret = NULL;

crypto/mem.c:293:2: 
  291.   void *CRYPTO_malloc(int num, const char *file, int line)
  292.   	{
  293. > 	void *ret = NULL;
  294.   	extern unsigned char cleanse_ctr;
  295.   

crypto/mem.c:296:6: Taking false branch
  294.   	extern unsigned char cleanse_ctr;
  295.   
  296.   	if (num < 0) return NULL;
              ^
  297.   
  298.   	allow_customize = 0;

crypto/mem.c:298:2: 
  296.   	if (num < 0) return NULL;
  297.   
  298. > 	allow_customize = 0;
  299.   	if (malloc_debug_func != NULL)
  300.   		{

crypto/mem.c:299:6: Taking true branch
  297.   
  298.   	allow_customize = 0;
  299.   	if (malloc_debug_func != NULL)
              ^
  300.   		{
  301.   		allow_customize_debug = 0;

crypto/mem.c:301:3: 
  299.   	if (malloc_debug_func != NULL)
  300.   		{
  301. > 		allow_customize_debug = 0;
  302.   		malloc_debug_func(NULL, num, file, line, 0);
  303.   		}

crypto/mem.c:302:3: Skipping __function_pointer__(): unresolved function pointer
  300.   		{
  301.   		allow_customize_debug = 0;
  302.   		malloc_debug_func(NULL, num, file, line, 0);
           ^
  303.   		}
  304.   	ret = malloc_ex_func(num,file,line);

crypto/mem.c:304:2: Skipping __function_pointer__(): unresolved function pointer
  302.   		malloc_debug_func(NULL, num, file, line, 0);
  303.   		}
  304.   	ret = malloc_ex_func(num,file,line);
          ^
  305.   #ifdef LEVITTE_DEBUG_MEM
  306.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:308:6: Taking true branch
  306.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
  307.   #endif
  308.   	if (malloc_debug_func != NULL)
              ^
  309.   		malloc_debug_func(ret, num, file, line, 1);
  310.   

crypto/mem.c:309:3: Skipping __function_pointer__(): unresolved function pointer
  307.   #endif
  308.   	if (malloc_debug_func != NULL)
  309.   		malloc_debug_func(ret, num, file, line, 1);
           ^
  310.   
  311.           /* Create a dependency on the value of 'cleanse_ctr' so our memory

crypto/mem.c:314:12: Taking false branch
  312.            * sanitisation function can't be optimised out. NB: We only do
  313.            * this for >2Kb so the overhead doesn't bother us. */
  314.           if(ret && (num > 2048))
                    ^
  315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
  316.   

crypto/mem.c:317:2: 
  315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
  316.   
  317. > 	return ret;
  318.   	}
  319.   

crypto/mem.c:318:2: return from a call to CRYPTO_malloc
  316.   
  317.   	return ret;
  318.   	}
          ^
  319.   
  320.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

test/dummytest.c:32:3: 
30.   		{
31.   		program = OPENSSL_malloc((q - p) + 1);
32. > 		strncpy(program, p, q - p);
33.   		program[q - p] = '\0';
34.   		}

int main(int argc, char *argv[])
	{
	char *p, *q = 0, *program;
	p = strrchr(argv[0], '/');
	if (!p) p = strrchr(argv[0], '\\');
#ifdef OPENSSL_SYS_VMS
	if (!p) p = strrchr(argv[0], ']');
	if (p) q = strrchr(p, '>');
	if (q) p = q;
	if (!p) p = strrchr(argv[0], ':');
	q = 0;
#endif
	if (p) p++;
	if (!p) p = argv[0];
	if (p) q = strchr(p, '.');
	if (p && !q) q = p + strlen(p);
	if (!p)
		program = BUF_strdup("(unknown)");
	else
		{
		program = OPENSSL_malloc((q - p) + 1);
		strncpy(program, p, q - p);
		program[q - p] = '\0';
		}
	for(p = program; *p; p++)
		if (islower((unsigned char)(*p)))
			*p = toupper((unsigned char)(*p));
	q = strstr(program, "TEST");
	if (q > p && q[-1] == '_') q--;
	*q = '\0';
	printf("No %s support\n", program);
	OPENSSL_free(program);
	return(0);
	}
['int main(int argc, char *argv[])\n\t{\n\tchar *p, *q = 0, *program;\n\tp = strrchr(argv[0], \'/\');\n\tif (!p) p = strrchr(argv[0], \'\\\\\');\n#ifdef OPENSSL_SYS_VMS\n\tif (!p) p = strrchr(argv[0], \']\');\n\tif (p) q = strrchr(p, \'>\');\n\tif (q) p = q;\n\tif (!p) p = strrchr(argv[0], \':\');\n\tq = 0;\n#endif\n\tif (p) p++;\n\tif (!p) p = argv[0];\n\tif (p) q = strchr(p, \'.\');\n\tif (p && !q) q = p + strlen(p);\n\tif (!p)\n\t\tprogram = BUF_strdup("(unknown)");\n\telse\n\t\t{\n\t\tprogram = OPENSSL_malloc((q - p) + 1);\n\t\tstrncpy(program, p, q - p);\n\t\tprogram[q - p] = \'\\0\';\n\t\t}\n\tfor(p = program; *p; p++)\n\t\tif (islower((unsigned char)(*p)))\n\t\t\t*p = toupper((unsigned char)(*p));\n\tq = strstr(program, "TEST");\n\tif (q > p && q[-1] == \'_\') q--;\n\t*q = \'\\0\';\n\tprintf("No %s support\\n", program);\n\tOPENSSL_free(program);\n\treturn(0);\n\t}', 'void *CRYPTO_malloc(int num, const char *file, int line)\n\t{\n\tvoid *ret = NULL;\n\textern unsigned char cleanse_ctr;\n\tif (num < 0) return NULL;\n\tallow_customize = 0;\n\tif (malloc_debug_func != NULL)\n\t\t{\n\t\tallow_customize_debug = 0;\n\t\tmalloc_debug_func(NULL, num, file, line, 0);\n\t\t}\n\tret = malloc_ex_func(num,file,line);\n#ifdef LEVITTE_DEBUG_MEM\n\tfprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\\n", ret, num);\n#endif\n\tif (malloc_debug_func != NULL)\n\t\tmalloc_debug_func(ret, num, file, line, 1);\n        if(ret && (num > 2048))\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\treturn ret;\n\t}']