Skip to content

Commit

Permalink
fix some more bugs that gcc warnings caught
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnl committed May 10, 2019
1 parent aff27de commit 76d8dc6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion popt/popt.c
Expand Up @@ -591,7 +591,7 @@ expandNextArg(/*@special@*/ poptContext con, const char * s)
*te = '\0';
t = realloc(t, tn);
te = t + strlen(t);
strncpy(te, a, alen); te += alen;
memcpy(te, a, alen); te += alen;
continue;
/*@notreached@*/ /*@switchbreak@*/ break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/srvrpc.c
Expand Up @@ -170,7 +170,7 @@ int dcc_r_many_files(int in_fd,
/* We should explain what happened here, but we have already read
* a few more bytes.
*/
strncpy(buf, token, 4);
memcpy(buf, token, 4);
/* TODO(manos): this is probably not kosher */
memcpy(&buf[4], &link_or_file_len, sizeof(link_or_file_len));
dcc_explain_mismatch(buf, 12, in_fd);
Expand Down
4 changes: 2 additions & 2 deletions src/stats.c
Expand Up @@ -133,8 +133,8 @@ void dcc_stats_compile_ok(char *compiler, char *filename, struct timeval start,
memcpy(&(sd.start), &start, sizeof(struct timeval));
memcpy(&(sd.stop), &stop, sizeof(struct timeval));
sd.time = time_usec;
strncpy(sd.filename, filename, MAX_FILENAME_LEN);
strncpy(sd.compiler, compiler, MAX_FILENAME_LEN);
strncpy(sd.filename, filename, MAX_FILENAME_LEN - 1);
strncpy(sd.compiler, compiler, MAX_FILENAME_LEN - 1);
dcc_writex(dcc_statspipe[1], &sd, sizeof(sd));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/util.c
Expand Up @@ -265,7 +265,8 @@ int dcc_get_dns_domain(const char **domain_name)
hstrerror(h_errno));
return -1;
}
strncpy(host_name, h->h_name, sizeof(host_name));
strncpy(host_name, h->h_name, sizeof(host_name - 1));
host_name[sizeof(host_name) - 1] = '\0';
}
envh = host_name;
}
Expand Down

0 comments on commit 76d8dc6

Please sign in to comment.