Commit Graph

7 Commits

Author SHA1 Message Date
Matthias Schiffer a5259c0245
autoupdater: improve handling of interrupted HTTP requests
Check return code of uloop_run() and pass the signal number up when the
loop was interrupted. After cleanup, uninstall uloop's signal handlers
and re-raise the signal to terminate the process.

This allows interrupting the autoupdater using Ctrl-C during downloads,
instead of having it continue with the next mirror (if multple are
configured). As uloop's signal handlers only set a flag to interrupt
uloop_run() and have otherwise no effect, the autoupdater can still only
be interrupted during HTTP requests, ensuring we can't leave the system
in an inconsistent state.
2023-02-24 22:34:26 +01:00
Matthias Schiffer e4bd7a4549
autoupdater: uclient: fix segfault after interrupted HTTP request
uloop_run() may finish without ever reaching request_done(), for example
when the main loop is interrupted by a signal. In this case,
uclient_disconnect() was never called, leaving a number of callbacks
like timeout handlers registered in the uloop context.

When the main loop was later resumed in a subsequent HTTP request without
completely reinitializing the uloop context, these timeout handlers could
still fire, even though the old uclient context had already been freed,
resulting in a use-after-free.

To avoid this, move the uclient_disconnect() call out of request_done()
to ensure that it is always called before uclient_free().
2023-02-24 21:00:02 +01:00
Matthias Schiffer 5521926500
autoupdater: uclient: remove early returns from get_url()
Simplify control flow by removing early returns. This allows us to
deduplicate cleanup (uclient_free() for now).
2023-02-24 20:59:58 +01:00
citronalco 83534952a5
autoupdater: Add HTTP-Header X-FIRMWARE-VERSION (#246)
X-FIRMWARE-VERSION gets set to the content of the file referenced by UCI setting "autoupdater.settings.version_file"
If "autoupdater.settings.version_file" is unset X-FIRMWARE-VERSION is
omitted
2021-07-16 19:25:06 +02:00
Tobias c802276581 autoupdater: uclient: fix nullpointer dereference on invalid URL (#183)
Previously supplying an invalid url for download would result in
uclient_new returning NULL and crash the autoupdater as soon as
cl->priv is accessed.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
2018-02-19 17:10:44 +01:00
Matthias Schiffer fc194bc7c8
autoupdater: uclient: add error handling in connection setup
Avoids a segfault when the connection fails early.
2018-01-22 10:57:35 +01:00
Jan-Philipp Litza 49cb4b3fdb
autoupdater: new implementation
This new version of the autoupdater is implemented in C instead of Lua,
allowing us to interface with libuclient (HTTP downloads) and libecdsautil
(signature checks) directly instead of spawning external processes,
saving RAM and making error handling more robust.

[Matthias Schiffer: add commit message]
2018-01-13 00:22:27 +01:00