* Clean up minor warnings from LGTM.com
LGTM (Semmie) is a tool, bought by GitHub last year, that conducts basic
linting tasks on code and HTML.
Clean up the warnings identified in the latest report:
https://lgtm.com/projects/g/esp8266/Arduino/?mode=list
No functionality should change, however this may fix some issues with
the perl utilities not exiting properly on a Ctrl-C from the command
line.
* Back out HTML changes and rerun boards.txt.py
Run valgrind on host mock example runs to catch more bugs in CI. These
tests would have caught the problem in #7464 before users did.
Add a list of some randomly picked examples to run, and add an option to
run the loop exactly once in the host mock routine, so the test will
actually exit under valgrind.
In the HTTPS example we were using a fingerprint which changes almost
daily as the github.com certificates are regenerated. Replace this with
a trust anchor based on the ultimate root CA that github.com uses to
sign their certificates. Assuming they don't change CAs, this
certificate should be good until 2030+
Fixes#7489
* CVE-2020-12638 workaround for WPA downgrade attack
When connected to an encrypted (WEP/WPA) router, a rogue packet can
cause the ESP8266 WiFi stack to drop to an unecrypted rogue network of
the same SSID.
Handle this by dropping the WiFi connection immediately and reconnecting
to the stored WPA/WEP network requested by the application, whenever the
AUTHMODE changes to OPEN from a secured mode.
https://lbsfilm.at/blog/wpa2-authenticationmode-downgrade-in-espressif-microprocessors
for more details.
PR #7464 removed the reset of client authentication settings when server
authentication settings were changed, however it never did initialize
the client authentication information to nullptr in the constructor.
This can result in crashes during connections when client certs are not
applied.
Fix by resetting the client authenticaion variables on object
construction.
WiFiClientSecure.setInsecure() was clearing the secret key (but not the
_chain public client cert) incorrectly. The other server authentication
modes also had the same effect.
The only way for it to work would be if the app first set the server
authentication method and then the client keys. There's no good reason
for this.
Adjust the connection to only clear the server id methods and leave the
client ID untouched.
Fixes#7455
* remove lwip-v1.4 specific code
* ditto
* ditto
* fix ip4_addr definition
* CI: change debug builds to use IPv6, remove regular IPv6 builds
* ditto
* split pio CI in four (because they last twice the time of the other builds)
* remove option from pio
* remove lwIP-1.4 from doc
* restore pio CI splitting
* fix CI debug6 script
* ditto
The BearSSL SigningVerifier was moved to the 2nd stack because some uses
required much more stack than available on the normal stack.
Add a reference to the second stack on object creation (which will
allocate it, if there is no BSSL stack already allocated), and delete
that reference on exit.
Fixes#7288
* Deprecate SPIFFS, move examples to LittleFS
SPIFFS has been a great filesystem, but it has significant problems in
many cases (and it's also pretty slow). Development seems to have
slowed/stopped on the upstream version, and we're not able to provide
support or fix the known issues with it as-is.
Deprecate SPIFFS variable.
Update all examples to use LittleFS instead of SPIFFS.
Also, minor cleanup on very old examples which has obsolete delays
waiting for the Serial port to come up, or which were stuck at 9600 baud
because of their ancient AVR heritage.
Fixes#7095
* Remove leftover debug code
* Clean up comments in some examples
* Update documentation on SPIFFS deprecation
* Fix host tests to avoid deprecation warnings
* Fix cut-n-paste error
* Restore SpeedTest.ino, adjust to allow custom FSes
Co-authored-by: Develo <deveyes@gmail.com>
Add minor NULL and double-free checks to source, identified using GCC10
pre-release static `-fanalyzer` on the coude. These are harmless to
other versions.
Also add explicit include of stdint to Schedule.h, because libstdc++20
will not automatically include it. Safe and no-op on earlier versions.
Fixes exception 28 in IPAddress(const ipv4_addr* fw_addr); with null ip_addr
pointer passed in by WiFiCient.cpp localIP(). I assumed that localIP()
was called shortly after _pcb became null.
lwIP's tcp/udp_connect() and tcp/udp_bind() functions automatically
set the zone if it is required but missing, but udp_connect() is not
used so this doesn't happen.
Explicitly set the zone to the default network interface if it is
required for the type of address being used. Otherwise there is no
zone set and packets to a link local destination don't go anywhere.
* Make DNS resolution order selectable during runtime or compile time (only in dual stack mode).
* Extend IPv6 example to show usage of new hostByName function with selectable resolving order
* Fix function definition of fqdn_rt in IPv6.ino.
* Fix function call.
* Fix missing bracket...
* Only run if built with dual stack support
* Make DNS resolution order selectable during runtime or compile time (only in dual stack mode).
* Extend IPv6 example to show usage of new hostByName function with selectable resolving order
* Fix function definition of fqdn_rt in IPv6 example.
* Implement enum class for resolve type
* Fix example IPv6.ino
* Fix typedef in ESP8266WiFiGeneric.h function call
* Change enum class definition to not depend on lwip/dns.h
* Move err_t err definition outside switch. Fix typecast.
* Always define DNSResolveType as pio test otherwise failes even if the enum class isn't used.
Co-authored-by: altelch <heiko.krupp@rhrk.uni-kl.de>
Co-authored-by: david gauchard <gauchard@laas.fr>
* wifi: ARP gratuitous API for wifi station mode
* fix with lwip1
* update comment
* update API to allow changing interval on the fly
* update API
* remove debug lines
* mock lwIP's etharp_request()
* unsigned interval
* use scheduled ticker
* ticker: +attach_ms_scheduled_accurate
ticker: +comment
gratuitous: use attach_ms_scheduled_accurate
* move to experimental namespace
* fix for lwIP-v1.4
* attempt to make pio happy
* use directly ETSTimer instead of Ticker
* Use 2nd stack for update signature verification
Fixes#7145
When doing a signed update, the signature calculation can use a lot of
stack, so move it silently to the BearSSL second stack.
Also fix a memory leak of signature-bytes found by @JiriBilek
* Reset state on any error condition in Updater::end
* Fix/enable UDP packet reassembly
UdpContext didn't care about pbuf chaining when receiving datagrams, leading
to fragments delivered to the application as individual packets.
* Provide pbuf_get_contiguous for backwards compatibility with LwIP 1.4
Implementation copied verbatim from LwIP 2.1.2
* Cosmetic changes to meet coding style
Co-authored-by: david gauchard <gauchard@laas.fr>
Co-authored-by: Develo <deveyes@gmail.com>
* upstream lwIP is now downloaded by a makefile, not subsubmoduled
* lwip2: upstream lwIP not sub-sub-modules anymore
lwip2: Allow IPv4 and IPv6 DNS and SNTP server configured via DHCP to co-exist (patch against upstream)
* lwip2: enable tcp-listen-with-backlog feature
* lwip2 submodule update:
- enable more efficient chksum algorithm thanks to Richard Allen
- enable tcp listener with backlog
* more comments, fix backlog management, fix API
* move default value definition in .cpp
because one must not believe it can be redefined before including WiFiServer.h
* improved backlog handling, it is no more a breaking change
In some cases, `initCertStore` may need to be called multiple times
(i.e. to update certs w/oa reboot). In that case, the saved file names
leaked when the new ones were `malloc()`'d.
Fix by freeing the old strings, if present.
This commit avoids OOMs on an udp corner case where a delay() in the main
loop would allow memory filling.
A memory leak has been observed with such semantically forbidden delay,
unsolved yet, and preventing to use a simple counter instead of walking
through a linked list. The count limit is however small.
Fixes#6811 which found an issue where connecting to scripts.google.com
would *occasionally* cause a crash. On inspection, it was found that up
to 5828 bytes of stack were used once in a while, so expand the stack to
5900 bytes to cover this case plus a little extra.
* Put longer string literals into PROGMEM
* Use Flash Strings for Debug output
This is hopefully very infrequently used, so it shouldn't
be in main memory.
* Fix WiFiClientSecure::available blocking
Added a check of WiFiClient::availableForWrite to prevent blocking writes when the _run_until blocking flag is false
* change availForWrite from int to size_t
* add timeout to _run_until loop
fixes#6464
* use polledTimeout with _timeout millis
* Move all scripts and documentation to Python3
Python 2 EOL is Jan 1, 2020. Migrate scripts to run under Python 3.
Under Windows, we're already running Python 3.7, by dumb luck. The
oddness is that the Windows standalone executable for Python 3 is called
"python" whereas under UNIX-like OSes it's called "python3" with
"python" always referring to the Python 2 executable. The ZIP needs to
be updated to include a Python3.exe (copy of Python.exe) so that we can
use the same command lines under Linux and Windows, and to preserve my
sanity.
Fixes#6376
* Add new Windows ZIP with python3.exe file
* Sort options in boards.txt generation for repeatability
The order of the board opts dict changes depending on the Python version
and machine, so sort the options before printing them to get a stable
ordering.
* Re-add Python2 compatibility tweaks
Most scripts can run as Python 2 or Python 3 with minimal changes, so
re-add (and fix, as necessary) compatibility tweaks to the scripts.
* Per @earlephilhower suggestion
* Hints from @earlephilhower
* Namespace BearSSL in core "feels" wrong - using catch-all esp8266 instead.
* After review remarks by @earlephilhower
This PR stops the 1ms-delay loop also when a tcp error occurs (previously this was done only when tcp had just connected or a write/send had succeeded).
The tcp error can be any, in this case with pubsubclient it is "connection refused" after the mqtt server disappeared and pubsubclient tries to reconnect.
A typo was present in several ifdefs which would allow a server to negotiate
an EC connection even when in basic SSL mode. When this happened, a crash
would occur (since there were no EC or advanced AES modes installed).
Fix the typo, fixes#6397