apps/ca.c:3034: error: NULL_DEREFERENCE
  pointer `tmp` last assigned on line 3032 could be null and is dereferenced by call to `strchr()` at line 3034, column 6.
Showing all 49 steps of the trace


apps/ca.c:3024:1: start of procedure unpack_revinfo()
3022.   	}
3023.   
3024. > int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME **pinvtm, char *str)
3025.   	{
3026.   	char *tmp = NULL;

apps/ca.c:3026:2: 
3024.   int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME **pinvtm, char *str)
3025.   	{
3026. > 	char *tmp = NULL;
3027.   	char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
3028.   	int reason_code = -1;

apps/ca.c:3027:2: 
3025.   	{
3026.   	char *tmp = NULL;
3027. > 	char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
3028.   	int reason_code = -1;
3029.   	int i, ret = 0;

apps/ca.c:3028:2: 
3026.   	char *tmp = NULL;
3027.   	char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
3028. > 	int reason_code = -1;
3029.   	int i, ret = 0;
3030.   	ASN1_OBJECT *hold = NULL;

apps/ca.c:3029:2: 
3027.   	char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
3028.   	int reason_code = -1;
3029. > 	int i, ret = 0;
3030.   	ASN1_OBJECT *hold = NULL;
3031.   	ASN1_GENERALIZEDTIME *comp_time = NULL;

apps/ca.c:3030:2: 
3028.   	int reason_code = -1;
3029.   	int i, ret = 0;
3030. > 	ASN1_OBJECT *hold = NULL;
3031.   	ASN1_GENERALIZEDTIME *comp_time = NULL;
3032.   	tmp = BUF_strdup(str);

apps/ca.c:3031:2: 
3029.   	int i, ret = 0;
3030.   	ASN1_OBJECT *hold = NULL;
3031. > 	ASN1_GENERALIZEDTIME *comp_time = NULL;
3032.   	tmp = BUF_strdup(str);
3033.   

apps/ca.c:3032:2: 
3030.   	ASN1_OBJECT *hold = NULL;
3031.   	ASN1_GENERALIZEDTIME *comp_time = NULL;
3032. > 	tmp = BUF_strdup(str);
3033.   
3034.   	p = strchr(tmp, ',');

crypto/buffer/buffer.c:165:1: start of procedure BUF_strdup()
  163.   	}
  164.   
  165. > char *BUF_strdup(const char *str)
  166.   	{
  167.   	char *ret;

crypto/buffer/buffer.c:170:6: Taking false branch
  168.   	int n;
  169.   
  170.   	if (str == NULL) return(NULL);
              ^
  171.   
  172.   	n=strlen(str);

crypto/buffer/buffer.c:172:2: 
  170.   	if (str == NULL) return(NULL);
  171.   
  172. > 	n=strlen(str);
  173.   	ret=OPENSSL_malloc(n+1);
  174.   	if (ret == NULL) 

crypto/buffer/buffer.c:173:2: 
  171.   
  172.   	n=strlen(str);
  173. > 	ret=OPENSSL_malloc(n+1);
  174.   	if (ret == NULL) 
  175.   		{

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)

crypto/buffer/buffer.c:174:6: Taking true branch
  172.   	n=strlen(str);
  173.   	ret=OPENSSL_malloc(n+1);
  174.   	if (ret == NULL) 
              ^
  175.   		{
  176.   		BUFerr(BUF_F_BUF_STRDUP,ERR_R_MALLOC_FAILURE);

crypto/buffer/buffer.c:176:3: 
  174.   	if (ret == NULL) 
  175.   		{
  176. > 		BUFerr(BUF_F_BUF_STRDUP,ERR_R_MALLOC_FAILURE);
  177.   		return(NULL);
  178.   		}

crypto/err/err.c:619:1: start of procedure ERR_put_error()
    617.   /********************************************************/
    618.   
    619. > void ERR_put_error(int lib, int func, int reason, const char *file,
    620.   	     int line)
    621.   	{

crypto/err/err.c:643:2: Skipping ERR_get_state(): empty list of specs
    641.   	}
    642.   #endif
    643.   	es=ERR_get_state();
            ^
    644.   
    645.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:645:2: 
    643.   	es=ERR_get_state();
    644.   
    645. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    646.   	if (es->top == es->bottom)
    647.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:646:6: Taking false branch
    644.   
    645.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    646.   	if (es->top == es->bottom)
                ^
    647.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    648.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:648:2: 
    646.   	if (es->top == es->bottom)
    647.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    648. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    649.   	es->err_file[es->top]=file;
    650.   	es->err_line[es->top]=line;

crypto/err/err.c:649:2: 
    647.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    648.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    649. > 	es->err_file[es->top]=file;
    650.   	es->err_line[es->top]=line;
    651.   	err_clear_data(es,es->top);

crypto/err/err.c:650:2: 
    648.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    649.   	es->err_file[es->top]=file;
    650. > 	es->err_line[es->top]=line;
    651.   	err_clear_data(es,es->top);
    652.   	}

crypto/err/err.c:651:2: Taking true branch
    649.   	es->err_file[es->top]=file;
    650.   	es->err_line[es->top]=line;
    651.   	err_clear_data(es,es->top);
            ^
    652.   	}
    653.   

crypto/err/err.c:651:2: Taking true branch
    649.   	es->err_file[es->top]=file;
    650.   	es->err_line[es->top]=line;
    651.   	err_clear_data(es,es->top);
            ^
    652.   	}
    653.   

crypto/mem.c:367:1: start of procedure CRYPTO_free()
      365.   	}
      366.   
      367. > void CRYPTO_free(void *str)
      368.   	{
      369.   	if (free_debug_func != NULL)

crypto/mem.c:369:6: Taking true branch
      367.   void CRYPTO_free(void *str)
      368.   	{
      369.   	if (free_debug_func != NULL)
                  ^
      370.   		free_debug_func(str, 0);
      371.   #ifdef LEVITTE_DEBUG_MEM

crypto/mem.c:370:3: Skipping __function_pointer__(): unresolved function pointer
      368.   	{
      369.   	if (free_debug_func != NULL)
      370.   		free_debug_func(str, 0);
               ^
      371.   #ifdef LEVITTE_DEBUG_MEM
      372.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         < 0x%p\n", str);

crypto/mem.c:374:2: Skipping __function_pointer__(): unresolved function pointer
      372.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         < 0x%p\n", str);
      373.   #endif
      374.   	free_func(str);
              ^
      375.   	if (free_debug_func != NULL)
      376.   		free_debug_func(NULL, 1);

crypto/mem.c:375:6: Taking true branch
      373.   #endif
      374.   	free_func(str);
      375.   	if (free_debug_func != NULL)
                  ^
      376.   		free_debug_func(NULL, 1);
      377.   	}

crypto/mem.c:376:3: Skipping __function_pointer__(): unresolved function pointer
      374.   	free_func(str);
      375.   	if (free_debug_func != NULL)
      376.   		free_debug_func(NULL, 1);
               ^
      377.   	}
      378.   

crypto/mem.c:375:2: 
      373.   #endif
      374.   	free_func(str);
      375. > 	if (free_debug_func != NULL)
      376.   		free_debug_func(NULL, 1);
      377.   	}

crypto/mem.c:377:2: return from a call to CRYPTO_free
      375.   	if (free_debug_func != NULL)
      376.   		free_debug_func(NULL, 1);
      377.   	}
              ^
      378.   
      379.   void *CRYPTO_remalloc(void *a, int num, const char *file, int line)

crypto/err/err.c:651:2: 
    649.   	es->err_file[es->top]=file;
    650.   	es->err_line[es->top]=line;
    651. > 	err_clear_data(es,es->top);
    652.   	}
    653.   

crypto/err/err.c:652:2: return from a call to ERR_put_error
    650.   	es->err_line[es->top]=line;
    651.   	err_clear_data(es,es->top);
    652.   	}
            ^
    653.   
    654.   void ERR_clear_error(void)

crypto/buffer/buffer.c:177:3: 
  175.   		{
  176.   		BUFerr(BUF_F_BUF_STRDUP,ERR_R_MALLOC_FAILURE);
  177. > 		return(NULL);
  178.   		}
  179.   	memcpy(ret,str,n+1);

crypto/buffer/buffer.c:181:2: return from a call to BUF_strdup
  179.   	memcpy(ret,str,n+1);
  180.   	return(ret);
  181.   	}
          ^
  182.   
  183.   size_t BUF_strlcpy(char *dst, const char *src, size_t size)

apps/ca.c:3034:2: 
3032.   	tmp = BUF_strdup(str);
3033.   
3034. > 	p = strchr(tmp, ',');
3035.   
3036.   	rtime_str = tmp;

int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME **pinvtm, char *str)
	{
	char *tmp = NULL;
	char *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;
	int reason_code = -1;
	int i, ret = 0;
	ASN1_OBJECT *hold = NULL;
	ASN1_GENERALIZEDTIME *comp_time = NULL;
	tmp = BUF_strdup(str);
	p = strchr(tmp, ',');
	rtime_str = tmp;
	if (p)
		{
		*p = '\0';
		p++;
		reason_str = p;
		p = strchr(p, ',');
		if (p)
			{
			*p = '\0';
			arg_str = p + 1;
			}
		}
	if (prevtm)
		{
		*prevtm = ASN1_UTCTIME_new();
		if (!ASN1_UTCTIME_set_string(*prevtm, rtime_str))
			{
			BIO_printf(bio_err, "invalid revocation date %s\n", rtime_str);
			goto err;
			}
		}
	if (reason_str)
		{
		for (i = 0; i < NUM_REASONS; i++)
			{
			if(!strcasecmp(reason_str, crl_reasons[i]))
				{
				reason_code = i;
				break;
				}
			}
		if (reason_code == OCSP_REVOKED_STATUS_NOSTATUS)
			{
			BIO_printf(bio_err, "invalid reason code %s\n", reason_str);
			goto err;
			}
		if (reason_code == 7)
			reason_code = OCSP_REVOKED_STATUS_REMOVEFROMCRL;
		else if (reason_code == 8)
			{
			if (!arg_str)
				{
				BIO_printf(bio_err, "missing hold instruction\n");
				goto err;
				}
			reason_code = OCSP_REVOKED_STATUS_CERTIFICATEHOLD;
			hold = OBJ_txt2obj(arg_str, 0);
			if (!hold)
				{
				BIO_printf(bio_err, "invalid object identifier %s\n", arg_str);
				goto err;
				}
			if (phold) *phold = hold;
			}
		else if ((reason_code == 9) || (reason_code == 10))
			{
			if (!arg_str)
				{
				BIO_printf(bio_err, "missing compromised time\n");
				goto err;
				}
			comp_time = ASN1_GENERALIZEDTIME_new();
			if (!ASN1_GENERALIZEDTIME_set_string(comp_time, arg_str))
				{
				BIO_printf(bio_err, "invalid compromised time %s\n", arg_str);
				goto err;
				}
			if (reason_code == 9)
				reason_code = OCSP_REVOKED_STATUS_KEYCOMPROMISE;
			else
				reason_code = OCSP_REVOKED_STATUS_CACOMPROMISE;
			}
		}
	if (preason) *preason = reason_code;
	if (pinvtm) *pinvtm = comp_time;
	else ASN1_GENERALIZEDTIME_free(comp_time);
	ret = 1;
	err:
	if (tmp) OPENSSL_free(tmp);
	if (!phold) ASN1_OBJECT_free(hold);
	if (!pinvtm) ASN1_GENERALIZEDTIME_free(comp_time);
	return ret;
	}
['int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME **pinvtm, char *str)\n\t{\n\tchar *tmp = NULL;\n\tchar *rtime_str, *reason_str = NULL, *arg_str = NULL, *p;\n\tint reason_code = -1;\n\tint i, ret = 0;\n\tASN1_OBJECT *hold = NULL;\n\tASN1_GENERALIZEDTIME *comp_time = NULL;\n\ttmp = BUF_strdup(str);\n\tp = strchr(tmp, \',\');\n\trtime_str = tmp;\n\tif (p)\n\t\t{\n\t\t*p = \'\\0\';\n\t\tp++;\n\t\treason_str = p;\n\t\tp = strchr(p, \',\');\n\t\tif (p)\n\t\t\t{\n\t\t\t*p = \'\\0\';\n\t\t\targ_str = p + 1;\n\t\t\t}\n\t\t}\n\tif (prevtm)\n\t\t{\n\t\t*prevtm = ASN1_UTCTIME_new();\n\t\tif (!ASN1_UTCTIME_set_string(*prevtm, rtime_str))\n\t\t\t{\n\t\t\tBIO_printf(bio_err, "invalid revocation date %s\\n", rtime_str);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tif (reason_str)\n\t\t{\n\t\tfor (i = 0; i < NUM_REASONS; i++)\n\t\t\t{\n\t\t\tif(!strcasecmp(reason_str, crl_reasons[i]))\n\t\t\t\t{\n\t\t\t\treason_code = i;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tif (reason_code == OCSP_REVOKED_STATUS_NOSTATUS)\n\t\t\t{\n\t\t\tBIO_printf(bio_err, "invalid reason code %s\\n", reason_str);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (reason_code == 7)\n\t\t\treason_code = OCSP_REVOKED_STATUS_REMOVEFROMCRL;\n\t\telse if (reason_code == 8)\n\t\t\t{\n\t\t\tif (!arg_str)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "missing hold instruction\\n");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\treason_code = OCSP_REVOKED_STATUS_CERTIFICATEHOLD;\n\t\t\thold = OBJ_txt2obj(arg_str, 0);\n\t\t\tif (!hold)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "invalid object identifier %s\\n", arg_str);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (phold) *phold = hold;\n\t\t\t}\n\t\telse if ((reason_code == 9) || (reason_code == 10))\n\t\t\t{\n\t\t\tif (!arg_str)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "missing compromised time\\n");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tcomp_time = ASN1_GENERALIZEDTIME_new();\n\t\t\tif (!ASN1_GENERALIZEDTIME_set_string(comp_time, arg_str))\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "invalid compromised time %s\\n", arg_str);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (reason_code == 9)\n\t\t\t\treason_code = OCSP_REVOKED_STATUS_KEYCOMPROMISE;\n\t\t\telse\n\t\t\t\treason_code = OCSP_REVOKED_STATUS_CACOMPROMISE;\n\t\t\t}\n\t\t}\n\tif (preason) *preason = reason_code;\n\tif (pinvtm) *pinvtm = comp_time;\n\telse ASN1_GENERALIZEDTIME_free(comp_time);\n\tret = 1;\n\terr:\n\tif (tmp) OPENSSL_free(tmp);\n\tif (!phold) ASN1_OBJECT_free(hold);\n\tif (!pinvtm) ASN1_GENERALIZEDTIME_free(comp_time);\n\treturn ret;\n\t}', 'char *BUF_strdup(const char *str)\n\t{\n\tchar *ret;\n\tint n;\n\tif (str == NULL) return(NULL);\n\tn=strlen(str);\n\tret=OPENSSL_malloc(n+1);\n\tif (ret == NULL)\n\t\t{\n\t\tBUFerr(BUF_F_BUF_STRDUP,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tmemcpy(ret,str,n+1);\n\treturn(ret);\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}', 'void ERR_put_error(int lib, int func, int reason, const char *file,\n\t     int line)\n\t{\n\tERR_STATE *es;\n#ifdef _OSD_POSIX\n\tif (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {\n\t\tchar *end;\n\t\tfile += sizeof("*POSIX(")-1;\n\t\tend = &file[strlen(file)-1];\n\t\tif (*end == \')\')\n\t\t\t*end = \'\\0\';\n\t\tif ((end = strrchr(file, \'/\')) != NULL)\n\t\t\tfile = &end[1];\n\t}\n#endif\n\tes=ERR_get_state();\n\tes->top=(es->top+1)%ERR_NUM_ERRORS;\n\tif (es->top == es->bottom)\n\t\tes->bottom=(es->bottom+1)%ERR_NUM_ERRORS;\n\tes->err_buffer[es->top]=ERR_PACK(lib,func,reason);\n\tes->err_file[es->top]=file;\n\tes->err_line[es->top]=line;\n\terr_clear_data(es,es->top);\n\t}', 'void CRYPTO_free(void *str)\n\t{\n\tif (free_debug_func != NULL)\n\t\tfree_debug_func(str, 0);\n#ifdef LEVITTE_DEBUG_MEM\n\tfprintf(stderr, "LEVITTE_DEBUG_MEM:         < 0x%p\\n", str);\n#endif\n\tfree_func(str);\n\tif (free_debug_func != NULL)\n\t\tfree_debug_func(NULL, 1);\n\t}']