AnsweredAssumed Answered

UDP receive bug

Question asked by Eugene Ryabtsev on Jul 2, 2015
Latest reply on Jun 10, 2017 by avm

In MQX 4.2 in rtcs\source\tcpip\udp.c I see the following:

 

static void udp_return_req2socket_from_rx_queue(UDP_PARM_PTR parms, struct udp_rx_dgram_header * dgram_item)
{
  uint32_t dgram_size = 0; 

  dgram_size = dgram_item->size; 
   
  /* limit for the upper layer recv buffer */ 
  if(parms->udpword > dgram_size)
  {
    parms->udpword = dgram_size;
  }

  if(parms->saddr_ptr)
  {
    *parms->saddr_ptr = dgram_item->fromaddr;
  }
  memcpy(parms->udpptr, dgram_item->dgram, dgram_size);
  ((SOCKET_STRUCT_PTR)parms->ucb->SOCKET)->LINK_OPTIONS.RX = dgram_item->rx_linkopts;
}

 

I'd rather expect it to be more like this:

 

  ...
  memcpy(parms->udpptr, dgram_item->dgram, parms->udpword /* dgram_size */);
  ...

 

This seems to respectively cause and solve a system-crash-sized-problem in our application.

Outcomes