Skip to content

Commit

Permalink
more coverity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
postwait committed Aug 15, 2017
1 parent 409e0fa commit 44db1db
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions fq_bench.c
Expand Up @@ -89,24 +89,30 @@ static void parse_cli(int argc, char **argv) {
usage(argv[0]);
exit(0);
case 'h':
free(host);
host = strdup(optarg);
break;
case 'p':
port = atoi(optarg);
break;
case 'u':
free(user);
user = strdup(optarg);
break;
case 'P':
free(pass);
pass = strdup(optarg);
break;
case 't':
free(type);
type = strdup(optarg);
break;
case 'q':
free(queue_name);
queue_name = strdup(optarg);
break;
case 'e':
free(exchange);
exchange = strdup(optarg);
break;
case 'c':
Expand Down
3 changes: 2 additions & 1 deletion fq_utils.c
Expand Up @@ -141,7 +141,8 @@ void fq_debug_set_string(const char *s) {

/* then comma separated named */
if(strlen(s) > sizeof(copy) - 1) return;
strncpy(copy,s,sizeof(copy));
/* copy including null terminator */
memcpy(copy,s,strlen(s)+1);
while(NULL != (tok = strtok_r(tok ? NULL : copy, ",", &lastsep))) {
#define SETBIT(tok, A) do { \
if(!strcasecmp(tok, #A + 9)) fq_debug_bits |= A; \
Expand Down
2 changes: 1 addition & 1 deletion fqd_http.c
Expand Up @@ -490,7 +490,7 @@ fqd_http_add_checkpoint(struct http_req *req) {

/* validate chkptid format */
char ckid[48] = {0};
strncpy(ckid, chkptid, sizeof(ckid));
strncpy(ckid, chkptid, sizeof(ckid)-1);
const char *log_string = ckid;
char *sep = strchr(ckid, ':');
if (sep == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion fqd_peer.c
Expand Up @@ -141,11 +141,11 @@ fqd_peer_cleanup_hook(fq_client conn) {
int i;
fqd_peer_connection *peer;
peer = fq_client_get_userdata(conn);
if(peer->bindings) free(peer->bindings);
for(i=0;i<peer->n_bindings;i++) {
peer_binding_info *bi = peer->bindings[i];
free(bi->prog);
}
if(peer->bindings) free(peer->bindings);
if(peer->host) free(peer->host);
if(peer->user) free(peer->user);
if(peer->pass) free(peer->pass);
Expand Down

0 comments on commit 44db1db

Please sign in to comment.