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:
commit
ef378d87b6
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue