diff options
author | Andrew Turner <andrew@FreeBSD.org> | 2020-04-01 09:51:29 +0000 |
---|---|---|
committer | Andrew Turner <andrew@FreeBSD.org> | 2020-04-01 09:51:29 +0000 |
commit | 3a142cd10cfbc98ac30388badc697eecd4b49fc5 (patch) | |
tree | 6c70df42a9149916f26e778ce4cb23e42cf3e7bf /usr.sbin/jail | |
parent | 89064ec6ef0fac8b2c259b6c51a300fc6fa3d53e (diff) | |
download | src-3a142cd10cfbc98ac30388badc697eecd4b49fc5.tar.gz src-3a142cd10cfbc98ac30388badc697eecd4b49fc5.zip |
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
Notes
Notes:
svn path=/head/; revision=359505
Diffstat (limited to 'usr.sbin/jail')
-rw-r--r-- | usr.sbin/jail/config.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c index 6f63b9117b1c..e66d955ca218 100644 --- a/usr.sbin/jail/config.c +++ b/usr.sbin/jail/config.c @@ -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'; |