Removed alloca call for ARM-CGT compatibility

This commit is contained in:
robert committed 2025-04-07 09:08:22 -04:00
1 parent e0ccbadd25
commit e656b1c792
2 files changed
+10 -2

No files matched your search

+5 -1
View File
@@ -4365,7 +4365,11 @@ static void tx_dhcp_request_sel(struct mg_tcpip_if *ifp, uint32_t ip_req,
(ifp->enable_req_sntp ? 1 : 0));
size_t len = strlen(ifp->dhcp_name);
size_t olen = 21 + len + extra + 2 + 1; // Total length of options
uint8_t *opts = alloca(olen), *p = opts; // Allocate options
uint8_t opts_maxlen = 21 + sizeof(ifp->dhcp_name) + 2 + 2 + 1;
uint8_t opts[opts_maxlen]; // Allocate options (max size possible)
uint8_t *p = opts;
assert(olen <= sizeof(opts));
memset(opts, 0, sizeof(opts));
*p++ = 53, *p++ = 1, *p++ = 3; // Type: DHCP request
*p++ = 54, *p++ = 4, memcpy(p, &ip_srv, 4), p += 4; // DHCP server ID
*p++ = 50, *p++ = 4, memcpy(p, &ip_req, 4), p += 4; // Requested IP
+5 -1
View File
@@ -284,7 +284,11 @@ static void tx_dhcp_request_sel(struct mg_tcpip_if *ifp, uint32_t ip_req,
(ifp->enable_req_sntp ? 1 : 0));
size_t len = strlen(ifp->dhcp_name);
size_t olen = 21 + len + extra + 2 + 1; // Total length of options
uint8_t *opts = alloca(olen), *p = opts; // Allocate options
uint8_t opts_maxlen = 21 + sizeof(ifp->dhcp_name) + 2 + 2 + 1;
uint8_t opts[opts_maxlen]; // Allocate options (max size possible)
uint8_t *p = opts;
assert(olen <= sizeof(opts));
memset(opts, 0, sizeof(opts));
*p++ = 53, *p++ = 1, *p++ = 3; // Type: DHCP request
*p++ = 54, *p++ = 4, memcpy(p, &ip_srv, 4), p += 4; // DHCP server ID
*p++ = 50, *p++ = 4, memcpy(p, &ip_req, 4), p += 4; // Requested IP