Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/awin get_bootconf_option doesnt return the v...



details:   https://anonhg.NetBSD.org/src/rev/659f5c5f3a7d
branches:  trunk
changeset: 333605:659f5c5f3a7d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Nov 10 20:36:12 2014 +0000

description:
get_bootconf_option doesnt return the value null-terminated, so look for an awge0.mac-address value of exactly the correct length

diffstat:

 sys/arch/evbarm/awin/awin_machdep.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (44 lines):

diff -r 6a908be900dd -r 659f5c5f3a7d sys/arch/evbarm/awin/awin_machdep.c
--- a/sys/arch/evbarm/awin/awin_machdep.c       Mon Nov 10 19:44:08 2014 +0000
+++ b/sys/arch/evbarm/awin/awin_machdep.c       Mon Nov 10 20:36:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: awin_machdep.c,v 1.26 2014/11/10 17:56:08 jmcneill Exp $ */
+/*     $NetBSD: awin_machdep.c,v 1.27 2014/11/10 20:36:12 jmcneill Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.26 2014/11/10 17:56:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.27 2014/11/10 20:36:12 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -725,14 +725,18 @@
                char *mac_addr;
                snprintf(argname, sizeof(argname), "%s.mac-address",
                    device_xname(self));
+
                if (get_bootconf_option(boot_args, argname,
-                   BOOTOPT_TYPE_STRING, &mac_addr) &&
-                   ether_aton_r(enaddr, sizeof(enaddr), mac_addr) == 0) {
-                       prop_data_t pd;
-                       pd = prop_data_create_data(enaddr, sizeof(enaddr));
-                       KASSERT(pd != NULL);
-                       prop_dictionary_set(dict, "mac-address", pd);
-                       prop_object_release(pd);
+                   BOOTOPT_TYPE_STRING, &mac_addr)) {
+                       char mac[strlen("XX:XX:XX:XX:XX:XX") + 1];
+                       strlcpy(mac, mac_addr, sizeof(mac));
+                       if (!ether_aton_r(enaddr, sizeof(enaddr), mac)) {
+                               prop_data_t pd;
+                               pd = prop_data_create_data(enaddr, sizeof(enaddr));
+                               KASSERT(pd != NULL);
+                               prop_dictionary_set(dict, "mac-address", pd);
+                               prop_object_release(pd);
+                       }
                }
 
 #if AWIN_board == AWIN_cubieboard



Home | Main Index | Thread Index | Old Index