Merge pull request #3282 from orestisf1993/strncpy-to-memcpy

Replace strncpy call with memcpy when result is not NUL-terminated
This commit is contained in:
Ingo Bürk 2018-05-09 14:34:00 +02:00 committed by GitHub
commit ef378d87b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -309,7 +309,7 @@ int i3_send_msg(uint32_t type, const char *payload) {
char *buffer = smalloc(to_write);
char *walk = buffer;
strncpy(buffer, I3_IPC_MAGIC, strlen(I3_IPC_MAGIC));
memcpy(buffer, I3_IPC_MAGIC, strlen(I3_IPC_MAGIC));
walk += strlen(I3_IPC_MAGIC);
memcpy(walk, &len, sizeof(uint32_t));
walk += sizeof(uint32_t);

View File

@ -604,7 +604,7 @@ void handle_button(xcb_button_press_event_t *event) {
const size_t len = namelen + strlen("workspace \"\"") + 1;
char *buffer = scalloc(len + num_quotes, 1);
strncpy(buffer, "workspace \"", strlen("workspace \""));
memcpy(buffer, "workspace \"", strlen("workspace \""));
size_t inpos, outpos;
for (inpos = 0, outpos = strlen("workspace \"");
inpos < namelen;