@@ -565,13 +565,19 @@ static void populate_config(struct platform_powerpc *platform,
static char *iface_config_str(void *ctx, struct interface_config *config)
{
char *str;
+ unsigned int i;
+
+ /* never this short but necessary */
+ if (config->hwaddr_len < 2)
+ return NULL;
- /* todo: HWADDR size is hardcoded as 6, but we may need to handle
- * different hardware address formats */
- str = talloc_asprintf(ctx, "%02x:%02x:%02x:%02x:%02x:%02x,",
- config->hwaddr[0], config->hwaddr[1],
- config->hwaddr[2], config->hwaddr[3],
- config->hwaddr[4], config->hwaddr[5]);
+ pb_debug("%s: hwaddr len %d", __func__, config->hwaddr_len);
+ str = talloc_asprintf(ctx, "%02x:", config->hwaddr[0]);
+ for (i = 1; i < config->hwaddr_len-1; i++) {
+ str = talloc_asprintf_append(str, "%02x:", config->hwaddr[i]);
+ }
+ str = talloc_asprintf_append(str, "%02x,", config->hwaddr[config->hwaddr_len-1]);
+ pb_debug("%s: hwaddr: %s\n", __func__, str);
if (config->ignore) {
str = talloc_asprintf_append(str, "ignore");
@@ -639,6 +645,8 @@ static void update_network_config(struct platform_powerpc *platform,
for (i = 0; i < config->network.n_interfaces; i++) {
char *iface_str = iface_config_str(platform,
config->network.interfaces[i]);
+ if (iface_str == NULL)
+ continue;
val = talloc_asprintf_append(val, "%s%s",
*val == '\0' ? "" : " ", iface_str);
talloc_free(iface_str);
Store any hardware address up to the maximum size in NVRAM. Due to the way each octet is appended, a hardware address less than 2 can not be stored. Signed-off-by: Daniel M. Weeks <weeksd2@rpi.edu> --- discover/platform-powerpc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)