Wednesday 4 March 2015

UDP server problem with NodeMCU build 0.95 / nodemcu_20150213.bin

For an upcoming project I need to run a DNS server on the ESP8266 module (ESP-01). All this server has to do is reply to any DNS query with the modules' IP address.
Basically that is what some captive portals do.

I developed that script on nodemcu_20150212.bin without any significant trouble and it ran ok there.

To make use of the node.compile() option, I upgraded to the 20150213.bin but the MCU crashed and rebooted when trying to send back the DNS reply.

The LUA script looks like this:

 encodedns (query, transaction_id)  
 function decodedns(pl)  
      --do some magic  
 function encodedns(query, transaction_id)  
      --do some more magic  

The svr:send failed and crashed the mcu. It totally lacks all input sanitation and can easily be derailed, but that is another story.

Looking at the changes from 20150212 to 20150213, the only suspicious change was this:

  @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.  
 -#define LUAL_BUFFERSIZE          BUFSIZ  
 +#define LUAL_BUFFERSIZE          (BUFSIZ*4)  
  /* }================================================================== */  

I changed that back to the original buffer size and sure enough my script was fine again.

No comments:

Post a Comment