Use memmove to copy within a buffer
jail(8) would try to use strcpy to remove the interface from the start of an IP address. This is undefined, and on arm64 will result in unexpected IPv6 addresses. Fix this by using memmove top move the string. PR: 245102 Reported by: sbruno MFC after: 2 weeks Sponsored by: Innovate UK
This commit is contained in:
@@ -596,8 +596,8 @@ check_intparams(struct cfjail *j)
|
||||
if (cs || defif)
|
||||
add_param(j, NULL, IP__IP4_IFADDR, s->s);
|
||||
if (cs) {
|
||||
strcpy(s->s, cs + 1);
|
||||
s->len -= cs + 1 - s->s;
|
||||
memmove(s->s, cs + 1, s->len + 1);
|
||||
}
|
||||
if ((cs = strchr(s->s, '/')) != NULL) {
|
||||
*cs = '\0';
|
||||
@@ -617,8 +617,8 @@ check_intparams(struct cfjail *j)
|
||||
if (cs || defif)
|
||||
add_param(j, NULL, IP__IP6_IFADDR, s->s);
|
||||
if (cs) {
|
||||
strcpy(s->s, cs + 1);
|
||||
s->len -= cs + 1 - s->s;
|
||||
memmove(s->s, cs + 1, s->len + 1);
|
||||
}
|
||||
if ((cs = strchr(s->s, '/')) != NULL) {
|
||||
*cs = '\0';
|
||||
|
||||
Reference in New Issue
Block a user