Commit Graph

624 Commits

Author SHA1 Message Date
Richard Hughes
196dbec5ae trivial: Add fu_security_attrs_append_internal() for future code 2021-10-29 13:11:21 +01:00
Richard Hughes
5bb250846d trivial: Fix recently introduced gtkdoc warning 2021-10-29 11:38:04 +01:00
Richard Hughes
7453d59ccf trivial: Fix a small memory leak in the self tests 2021-10-27 15:57:53 +01:00
Richard Hughes
0d64780093 trivial: Fix a small memory leak when getting volumes 2021-10-27 15:57:53 +01:00
Richard Hughes
b3e7f07716 trivial: Use ->dispose() to remove a ref-loop at exit 2021-10-27 15:57:53 +01:00
Jason Gerecke
835975d66c trivial: Add "full" CRC8 function
The CRC32 and CRC16 algorithms have "full" functions that allow callers to
provide their own polynomial and initial CRC value. Provide the same ability
to users of the CRC8 algorithm.
2021-10-26 18:15:23 +01:00
Richard Hughes
28678235cd Move the fuzzing files into the plugin directories
We only had to pile everything into the src/fuzzing/firmware directory
because honggfuzz could not cope with more than one input path.

This way each plugin is self contained and easy to copy.
Also, install the fuzzing builder objects as this fixes the installed
tests when srcdir does not exist.

Based on a patch by Jan Tojnar <jtojnar@gmail.com>, many thanks.
2021-10-22 15:24:05 +01:00
Richard Hughes
3a63f5bd9b trivial: Make the SREC parser more spec compliant
Only upgrade S5 into S6 when there are over 0xFFFF records.
2021-10-22 14:58:24 +01:00
Richard Hughes
2d00cda464 Remove PLUGINBUILDDIR and use G_TEST_SRCDIR and G_TEST_BUILDDIR instead
This allows us to override the location we load data files from, which
allows us to do more kinds of installed tests in the future.

Also, move the global data/tests content into the place that it is used
as it was getting impossible to manage.
2021-10-21 18:36:22 +01:00
Mario Limonciello
3709dcd104 trivial: fix URL for fwupdagent security command
fixes: #3893
2021-10-21 09:34:04 -05:00
Richard Hughes
6235a8222a Share the Common Flash Memory Interface quirks between plugins
Now two plugins are using hardcoded SPI constants for various CFI chips,
and it makes sense to have some common quirk data that can be used by
both.

Add a FuSpiChip helper object that can be used by FuDevice subclasses
to get the specific SPI commands to use for each flash ID.
2021-10-20 12:19:39 +01:00
Richard Hughes
27e40c3025 trivial: Add more fuzzing alignment checks
In reality these are not super interesting as they only happen on
`->write()` and not `->parse()`.

In other news, the fuzzer now appreciates how critical the alignment
is, which is probably a good thing generally.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40088
2021-10-18 20:02:03 +01:00
Richard Hughes
e99dd242e9 Strip inner XML text when loading metainfo.xml files
This allows us to do the right thing if given an XML file with leading
or trailing space in the entry, e.g.

    <value key=LVFS::UpdateProtocol> org.uefi.capsule </value>
2021-10-18 14:43:57 +01:00
Richard Hughes
15bf534e3f Set the verfmt of the returned device when the daemon device is unset
This regressed in 1.5.5 when we migrated FWUPD_DEVICE_FLAG_MD_SET_VERFMT
into FU_DEVICE_INTERNAL_FLAG_MD_SET_VERFMT and forgot to copy the system
device internal flags.
2021-10-18 06:57:09 +01:00
Richard Hughes
9c7939dae3 trivial: Fix a fuzzing crash for a corrupt IFD image
Sanity check the alignment so we do not write gigabytes of 0xFF's.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39982
2021-10-15 20:05:55 +01:00
Richard Hughes
bd43647554 Add fu_usb_device_new_with_context() helpers
This means the context is set at construction time, which is much less
fragile than setting the context manually.
2021-10-15 15:59:34 +01:00
Richard Hughes
ccc0f9b0c6 trivial: Assign the context of incorporated devices early
This means we can use GObject->constructed() to copy the context over
to FuDevice helpers that also require the context.
2021-10-15 15:57:57 +01:00
Richard Hughes
dbf92be359 trivial: Add fu_device_add_string() for future use 2021-10-14 15:49:58 +01:00
Gaël PORTAY
918006f8d5 trivial: Codespell fixes 2021-10-14 09:09:54 -05:00
Gaël PORTAY
21b470c1a1 trivial: Codespell fixes 2021-10-14 09:09:54 -05:00
Richard Hughes
852a6dbdc2 redfish: Handle EPERM when testing devices with a IPMI device
Fixes https://github.com/fwupd/fwupd/issues/3849
2021-10-12 19:12:57 -05:00
Richard Hughes
357d7ff396 trivial: Fix up a docgen comment typo 2021-10-09 16:22:35 +01:00
Richard Hughes
d3706e0e0b Show the user a warning if updating may affect full-disk-encryption
Additionally, if the client does not set the feature flag `fde-warning`,
add an extra paragraph into the update description.

Fixes https://github.com/fwupd/fwupd/issues/3829
2021-10-09 08:09:38 +01:00
Richard Hughes
3f82205062 Support loading remotes from /var/lib/fwupd/remotes.d
This allows us to add remotes on /etc immutable systems.
2021-10-08 17:22:24 +01:00
Richard Hughes
1669f532be trivial: Move the metadata directory
This moves the cached metadata location from /var/lib/fwupd/remotes.d
to /var/lib/fwupd/metadata

The former was a bad name as it wasn't a list of remotes, and .d is the
suffix for directories the user can install files into, rather than for
binary content managed entirely by the daemon.
2021-10-08 17:22:24 +01:00
Richard Hughes
20a1b12afe trivial: Ensure paths in /var exist before starting the daemon
On an immutable system these might have been factory reset to empty.
2021-10-08 17:22:24 +01:00
Richard Hughes
c22c2e0752 trivial: Prevent a possible warning when using _FLAG_INHIBIT_CHILDREN 2021-10-07 17:42:39 +01:00
Richard Hughes
39d8baf516 trivial: Notify when the FuDevice:parent is set
This allows us to perform a callback when the parent instance is set or
changed.
2021-10-05 18:15:53 +01:00
Richard Hughes
88b1b35a72 trivial: Use new libgcab API where possible
This is new in version 1.5, but may be backported.
2021-10-05 18:15:37 +01:00
Richard Hughes
e3e84b717a Allow using interrupt transfers for HID devices
Also, print the interface number and EP addresses in the ->to_string
handler.
2021-10-05 15:08:44 +01:00
Richard Hughes
35fff9684e trivial: Export the CFU enum conversion functions
We need these in the CFU plugin too.
2021-09-25 21:16:18 +01:00
Richard Hughes
478e44bc19 trivial: Do not use g_assert() in self test code
Note that g_assert() should not be used in unit tests, since it is a
no-op when compiling with G_DISABLE_ASSERT. Use g_assert() in production
code, and g_assert_true() in unit tests.

See https://github.com/fwupd/fwupd/issues/3790
2021-09-24 22:20:21 +01:00
Richard Hughes
f302bbcb03 trivial: Fix a potential division by zero
Spotted by Coverity.
2021-09-24 19:03:52 +01:00
Richard Hughes
3a86c7e386 elantp: Use the recently added FuCfuOffer and FuCfuPayload
This increases the amount of parsing we do ahead-of-time.
2021-09-24 08:40:42 +01:00
Richard Hughes
907a60573d bcm57xx: Fix a FuProgress thinko 2021-09-21 16:20:20 +01:00
Richard Hughes
543ae52e23 Document some of the environment variables used by fwupd
Fixes https://github.com/fwupd/fwupd/issues/3760
2021-09-21 10:25:12 +01:00
Richard Hughes
450e8e1c17 Add FuCfuPayload and FuCfuOffer
We can use these in the future elantp plugin, and I'm sure we'll need
them again in the future for an *actual* CFU plugin.
2021-09-20 14:43:34 +01:00
Richard Hughes
1ff96eb4b3 Restore the ABI for fu_device_detach() and provide new symbols
Quite a few plugins are using a FuDeviceLocker to detach then attach in
the error path, and finding them isn't easy as we explicitly cast to a
FuDeviceLockerFunc.

For sanity, just provide both symbols so we can do the right thing in
both cases. It seems like a sensible thing to allow.

Fixes https://github.com/fwupd/fwupd/issues/3771
2021-09-17 16:35:21 +01:00
Richard Hughes
3162c8540d Add new API for splitting an untrusted string
Using fu_common_strnsplit() has the drawback that a malicious user (or
a fuzzer!) could create a file with 5,000,000 newlines, and then pass
that into any parser that tokenizes into lines. This causes millions of
tiny allocations and quickly dirties hundreds of megabytes of RSS due
to heap overheads.

Rather than splitting a huge array and then processing each line, set
up a callback to process each line and only allocate the next string if
the token was parsed correctly. This means that we don't even dup the
buffer before we start parsing, rather than allocating everything and
then failing at the first hurdle.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38696
2021-09-17 14:46:45 +01:00
Richard Hughes
320f8d7d90 Update the child composite ID if the parent changes
Typically, this can be triggered with:

 * create parent
 * set parent physical ID
 * add new child to parent
 * set parent logical ID
2021-09-16 07:44:44 +01:00
Richard Hughes
40cd18fa97 Allow using a per-device global percentage completion
It's actually quite hard to build a front-end for fwupd at the moment
as you're never sure when the progress bar is going to zip back to 0%
and start all over again. Some plugins go 0..100% for write, others
go 0..100% for erase, then again for write, then *again* for verify.

By creating a helper object we can easily split up the progress of the
specific task, e.g. write_firmware().

We can encode at the plugin level "the erase takes 50% of the time, the
write takes 40% and the read takes 10%". This means we can have a
progressbar which goes up just once at a consistent speed.
2021-09-13 14:28:15 +01:00
Richard Hughes
b3824c94fa Fix a regression in flashing the Dell dock
This fixes a regression caused by 15b668c, we should have been more careful.

Fixes https://github.com/fwupd/fwupd/issues/3732
2021-09-10 15:50:52 +01:00
Richard Hughes
8b47bbeb09 trivial: Allow setting the FuDevice context in a constructor
This allows devices to add instance IDs in object_class->constructed,
e.g. FuWacModule.
2021-09-08 15:49:19 +01:00
Richard Hughes
33a24c77b7 trivial: Add fu_plugin_set_config_value() for future usage 2021-09-07 17:25:37 +01:00
Richard Hughes
1a6414c41f trivial: Allow NULL GError for fu_device_locker_new()
It's correctly specified in the docs as 'nullable'.
2021-09-07 17:25:37 +01:00
Richard Hughes
fa64f8fd30 trivial: Fix a tiny memory leak for an invalid SREC file
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38196
2021-09-06 21:35:06 +01:00
Richard Hughes
9c6f676656 Actually check for parse errors when using fu_firmware_strparse_uintX_safe
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38141
2021-09-05 15:46:00 +01:00
Richard Hughes
d4fb04d6fc Allow overriding the quirks directory at runtime 2021-09-03 21:14:37 +01:00
Mario Limonciello
41c00ff404 trivial: libfwupdplugin: make the self tests not overwrite source folders 2021-09-03 15:10:38 -05:00
Mario Limonciello
65a7f87358 trivial: libfwupdplugin: remove unused PLUGINBUILDDIR 2021-09-03 15:10:38 -05:00