From a8d40eb7060170a235c0127b9e49878bb1ca671a Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Wed, 15 Nov 2023 22:02:07 +0800 Subject: [PATCH] fix ecm mac buffer size --- class/cdc/usbh_cdc_ecm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/class/cdc/usbh_cdc_ecm.c b/class/cdc/usbh_cdc_ecm.c index d78ff1fb..d4546927 100644 --- a/class/cdc/usbh_cdc_ecm.c +++ b/class/cdc/usbh_cdc_ecm.c @@ -62,7 +62,7 @@ static int usbh_cdc_ecm_connect(struct usbh_hubport *hport, uint8_t intf) struct usb_endpoint_descriptor *ep_desc; int ret; uint8_t altsetting = 0; - char mac_buffer[8]; + char mac_buffer[12]; uint8_t *p; uint8_t cur_iface = 0xff; uint8_t mac_str_idx = 0xff; @@ -111,9 +111,7 @@ static int usbh_cdc_ecm_connect(struct usbh_hubport *hport, uint8_t intf) return ret; } - uint8_t len = strlen(mac_buffer); - - for (int i = 0, j = 0; i < len; i += 2, j++) { + for (int i = 0, j = 0; i < 12; i += 2, j++) { char byte_str[3]; byte_str[0] = mac_buffer[i]; byte_str[1] = mac_buffer[i + 1]; @@ -123,7 +121,7 @@ static int usbh_cdc_ecm_connect(struct usbh_hubport *hport, uint8_t intf) cdc_ecm_class->mac[j] = (unsigned char)byte; } - USB_LOG_INFO("CDC ECM mac address %02x: %02x: %02x: %02x: %02x: %02x\r\n", + USB_LOG_INFO("CDC ECM MAC address %02x:%02x:%02x:%02x:%02x:%02x\r\n", cdc_ecm_class->mac[0], cdc_ecm_class->mac[1], cdc_ecm_class->mac[2],