From: Roy Marples Date: Thu, 2 Oct 2014 10:07:59 +0000 (+0000) Subject: Remove strcpy as it's "dangerous". X-Git-Tag: v6.5.0~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3bdae69ccff18fac1a6a95e8b5eef5854f3b74e7;p=thirdparty%2Fdhcpcd.git Remove strcpy as it's "dangerous". Can't use stpcpy for the same reason even though it's perfect for the job. --- diff --git a/dhcp6.c b/dhcp6.c index 744318b5..3ed743da 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -3383,7 +3383,7 @@ delegated: i = 0; TAILQ_FOREACH(ap, &state->addrs, next) { if (ap->delegating_iface) { - i += strlen(ap->saddr) + 1; + i += strlen(ap->saddr) + 1; } } if (env && i) { @@ -3396,8 +3396,12 @@ delegated: v += snprintf(val, i, "%s_dhcp6_prefix=", prefix); TAILQ_FOREACH(ap, &state->addrs, next) { if (ap->delegating_iface) { - strcpy(v, ap->saddr); - v += strlen(ap->saddr); + /* Can't use stpcpy(3) due to "security" */ + const char *sap = ap->saddr; + + do + *v++ = *sap; + while (*sap++ != '\0'); *v++ = ' '; } }