Commit Graph

23 Commits

Author SHA1 Message Date
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
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
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
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Richard Hughes
942802063e trivial: Remove the unused parent instance from the private struct
I assume at some point we forgot to remove it when converting an object
from FINAL to DERIVABLE and the anti-pattern just got copied around the
codebase...
2021-07-15 16:20:19 +01:00
Richard Hughes
351989ed9e trivial: Reduce the debug verbosity when reading SREC firmware 2021-06-18 14:03:54 +01:00
Richard Hughes
a02c1073f2 trivial: Fix up some of the developer docs
And add some missing content as requried.
2021-06-11 09:39:03 +01:00
Mario Limonciello
1e17457b16 Allow building the documentation with gi-docgen and gtk-doc
Until gi-docgen is declared stable support either of them.
This effectively means that hand builds and CI builds will use
gi-docgen, but distro builds use gtk-doc-tools.
2021-06-09 22:21:53 +01:00
Richard Hughes
8fe6a1dd0c trivial: Make FuSrecFirmwareRecord usable from non-C languages 2021-05-11 13:15:27 +01:00
Richard Hughes
20ef071b3c trivial: Style fixes to lots of gtk-doc 2021-05-10 14:35:10 +01:00
Richard Hughes
776a0890fe srec: Make FuIhexFirmware derivable for possible future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Richard Hughes
1c0ed3ab1d srec: Detect overflow to avoid adding ~4GB of 0xFF padding
Fixes https://oss-fuzz.com/testcase-detail/5468114109202432
2021-03-14 09:50:39 +00:00
Richard Hughes
d27bfc08fd srec: Fix a fuzzing failure when trying to build zero sized firmware 2021-03-11 15:48:02 +00:00
Richard Hughes
88969d10c4 srec: Actually include the address in the written data 2021-03-11 15:48:02 +00:00
Richard Hughes
7c0560c37f srec: Add support for writing firmware 2021-03-10 21:39:01 -06:00
Richard Hughes
1981c63d58 Remove FuFirmwareImage and just use FuFirmware instead
This allows us to 'nest' firmware formats, and removes a ton of duplication.

The aim here is to deprecate FuFirmwareImage -- it's almost always acting
as a 'child' FuFirmware instance, and even copies most of the vfuncs to allow
custom types. If I'm struggling to work out what should be a FuFirmware and
what should be a FuFirmwareImage then a plugin author has no hope.

For simple payloads we were adding bytes into an image and then the image into
a firmware. This gets really messy when most plugins are treating the FuFirmware
*as* the binary firmware file.

The GBytes saved in the FuFirmware would be considered the payload with the
aim of not using FuFirmwareImage in the single-image case.
2021-03-09 21:14:12 +00:00
Richard Hughes
60a4b56802 srec: Fix an overflow causing an infinite loop when parsing 2021-02-12 20:51:39 +00:00
Richard Hughes
54bc512388 Add firmware flags for presence of CRC and VID/PID 2021-02-11 20:27:20 +00:00
Richard Hughes
2e73bef923 Be more paranoid when parsing from ASCII buffers 2021-02-09 16:37:25 +00:00
Richard Hughes
647ec9677e trivial: Do not show unprintable text when parsing invalid SREC firmware 2021-01-06 10:08:45 +00:00
Richard Hughes
6450d0deb4 Add FwupdInstallFlags of _IGNORE_CHECKSUM, _IGNORE_VID_PID and _IGNORE_POWER
The FWUPD_INSTALL_FLAG_FORCE flag has really unclear semantics, and ignoring a
file CRC, checksum or model ID should only be done when using fwupdtool actually
debugging a plugin or firmware parser.

Use the existing --force flag when we want a "gentle nudge" like reuploading
previously processed reports.
2020-10-07 13:15:09 +01:00
Richard Hughes
00f66f659d trivial: Do not include non-introspectable functions in the GIR
If we do need these for managed languages, we can of course create boxed types
when requried.
2019-11-27 12:45:35 +00:00
Mario Limonciello
6b0e66354b Convert libfwupdprivate to a shared library libfwupdplugin 2019-11-27 11:32:43 +00:00