mirror of
				https://github.com/optim-enterprises-bv/nDPId.git
				synced 2025-10-29 17:32:23 +00:00 
			
		
		
		
	Fix issues detected by SonarCloud.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
		| @@ -1354,7 +1354,10 @@ int main(int argc, char ** argv) | ||||
|         } | ||||
|         return 1; | ||||
|     } | ||||
|     chmod(datadir, S_IRWXU); | ||||
|     if (datadir != NULL) | ||||
|     { | ||||
|         chmod(datadir, S_IRWXU); | ||||
|     } | ||||
|  | ||||
|     if (nDPIsrvd_set_read_timeout(sock, 180, 0) != 0) | ||||
|     { | ||||
|   | ||||
| @@ -726,7 +726,7 @@ static enum nDPIsrvd_callback_return collectd_json_callback(struct nDPIsrvd_sock | ||||
|         struct nDPIsrvd_json_token const * current = NULL; | ||||
|         int next_child_index = -1; | ||||
|  | ||||
|         if (flow_risk != NULL) | ||||
|         if (flow_risk != NULL && flow_user_data != NULL) | ||||
|         { | ||||
|             if (flow_user_data->detected_risks == 0) | ||||
|             { | ||||
| @@ -744,13 +744,12 @@ static enum nDPIsrvd_callback_return collectd_json_callback(struct nDPIsrvd_sock | ||||
|                         if (numeric_risk_value < NDPI_MAX_RISK && numeric_risk_value > 0) | ||||
|                         { | ||||
|                             collectd_statistics.flow_risk_count[numeric_risk_value - 1]++; | ||||
|                             flow_user_data->detected_risks |= (1ull << (numeric_risk_value - 1)); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             collectd_statistics.flow_risk_unknown_count++; | ||||
|                         } | ||||
|  | ||||
|                         flow_user_data->detected_risks |= (1ull << (numeric_risk_value - 1)); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -104,7 +104,7 @@ int main(void) | ||||
|                            json_bytes - json_start, | ||||
|                            tokens, | ||||
|                            sizeof(tokens) / sizeof(tokens[0])); | ||||
|             if (r < 0 || tokens[0].type != JSMN_OBJECT) | ||||
|             if (r < 1 || tokens[0].type != JSMN_OBJECT) | ||||
|             { | ||||
|                 fprintf(stderr, "JSON parsing failed with return value %d at position %u\n", r, parser.pos); | ||||
|                 fprintf(stderr, "JSON string: '%.*s'\n", (int)(json_bytes - json_start), (char *)(buf + json_start)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Toni Uhlig
					Toni Uhlig