]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove strcpy as it's "dangerous".
authorRoy Marples <roy@marples.name>
Thu, 2 Oct 2014 10:07:59 +0000 (10:07 +0000)
committerRoy Marples <roy@marples.name>
Thu, 2 Oct 2014 10:07:59 +0000 (10:07 +0000)
Can't use stpcpy for the same reason even though it's perfect for the job.

dhcp6.c

diff --git a/dhcp6.c b/dhcp6.c
index 744318b588cca6968cb46c4b9ae1941bc61fcc72..3ed743da5a2c72a3d73871c764ab6f014a17907a 100644 (file)
--- 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++ = ' ';
                        }
                }