board/BuR/common: use strlcpy instead of strncpy
authorBernhard Messerklinger <bernhard.messerklinger@br-automation.com>
Fri, 4 Apr 2025 07:27:57 +0000 (09:27 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 16 Apr 2025 13:39:48 +0000 (15:39 +0200)
Now strlcpy is used to copy the defip string to the corresponding
environment variable. This preserves memory for the NULL termination.

Signed-off-by: Bernhard Messerklinger <bernhard.messerklinger@br-automation.com>
Link: https://lore.kernel.org/r/20250404072819.69642-2-bernhard.messerklinger@br-automation.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
board/BuR/common/common.c

index 7fb6173..3513f43 100644 (file)
@@ -68,7 +68,7 @@ int brdefaultip_setup(int bus, int chip)
                         "if test -r ${ipaddr}; then; else setenv ipaddr 192.168.60.%d; setenv serverip 192.168.60.254; setenv gatewayip 192.168.60.254; setenv netmask 255.255.255.0; fi;",
                         u8buf);
        else
-               strncpy(defip,
+               strlcpy(defip,
                        "if test -r ${ipaddr}; then; else setenv ipaddr 192.168.60.1; setenv serverip 192.168.60.254; setenv gatewayip 192.168.60.254; setenv netmask 255.255.255.0; fi;",
                        sizeof(defip));