1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #1011 from ahf/otr-compiler-warning-fix

Use memcpy() instead of strncpy() to silence the compiler warning.
This commit is contained in:
ailin-nemui 2019-02-11 09:49:04 +01:00 committed by GitHub
commit ea41726b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -621,8 +621,10 @@ static enum otr_msg_status enqueue_otr_fragment(const char *msg, struct otr_peer
opc->msg_size += msg_len + 1;
}
/* Copy msg to full message since we already have a part pending. */
strncpy(opc->full_msg + opc->msg_len, msg, msg_len);
/* Copy msg to full message since we already have a part pending. Note
* that we do not copy `msg`'s trailing nul byte because we explicit
* set opc->full_msg[opc->msg_len] to nul afterwards. */
memcpy(opc->full_msg + opc->msg_len, msg, msg_len);
opc->msg_len += msg_len;
opc->full_msg[opc->msg_len] = '\0';
@ -664,7 +666,7 @@ static enum otr_msg_status enqueue_otr_fragment(const char *msg, struct otr_peer
return ret;
}
/* Copy full message with NULL terminated byte. */
strncpy(opc->full_msg, msg, msg_len);
memcpy(opc->full_msg, msg, msg_len);
opc->msg_len += msg_len;
opc->msg_size += ((msg_len * 2) + 1);
opc->full_msg[opc->msg_len] = '\0';