memory clearly has exit path through argument, factor out temporary
variable to silence cppcheck
Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
'key' argument must describe 'key' which triggered error message
to keep stderr output helpful.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
sec_buffer allocated inside elf_read_section()
was not being freed before and is freed now.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Add support of cavs extended manifest and modules. Now
we will have another config tgl-cavs for tgl.
Signed-off-by: Rander Wang <rander.wang@intel.com>
This comment is meant for "git grep salt", that's its main purpose.
Much more obvious timestamps aside, this new code is the only
non-deterministic part of rimage - learned the very hard way
(OpenSSL "documentation" calls it "sLen"...)
A/B testing of build system changes is much, much easier when
locally and temporarily making the build 100% deterministic.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This type was used by early versions of meu, but the hash is not
used in later versions. Leave the code in in case it has to come back.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add simple crc32 function to calculate the checksum for v2.5 headers.
Implementation is very simple using shift register as we don't require
speed. Calculate the v2.5 header checksum with crc-32/iso-hdlc
parameters.
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Also show useful "make help" that lists all targets.
Show -B option of CMake that avoids changing the current directory to
the build directory: especially inconvenient considering the
recommended, CMake way to clean is to delete this directory and the
recommended way to build multiple configurations is to use multiple
build directories.
-B was introduced in CMake 3.13 which has been released two years ago
now and CMake spoils its users with a choice of ways to upgrade:
https://cmake.org/download/https://apt.kitware.com/https://pypi.org/project/cmake/
This does _not_ imply CMakeLists.txt should drop backward compatibility
with CMake < 3.13. I only think a README.md file should not keep the
majority of users in the dark only for the convenience of a minority of
obsolete CMake users.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Any generated file should be tracked by git to keep repositiry clean.
Such an file should be added to .gitignore to reduce possibility of
accidentally pushig this file to remote branches, eg. after typing
`git add *` before pushing changes.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This approach allows to easily expand parsers list in future,
without harming code readability.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This task is fully separatable from adsp_parse_config_fd(),
so should be done in separate function, to improve code readability.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Found by chance and reproduced by making a typo in the key's filename.
Note there is already an (unchanged) error message:
pkcs: signing with key sof/keys/otc_private_key_3k.pemX
error: can't open file sof/keys/otc_private_key_3k.pemX -2
Firmware manifest and signing completed !
But now rimage does not pretend success and the build does not keep
going with an unsigned image like nothing happened.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
As suggested by Karol in the review of the next commit. Makes the
function call shorter and naming the parameters makes the code much more
readable. Can help for debugging too.
Absolutely zero change: the two CMAKE_BUILD_TYPE=Release rimage binaries
before and after this commit are actually identical.
In passing, replace void * arithmetic in that function
with char *. void * arithmetic is an actually illegal gcc
extension (not just "undefined").
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
ri_sha*() functions are often called with arguments calculated on
the fly, so at list basic assertion here may save debugging time
in the future.
Cast size to uint64_t to properly handle nagative sizes, casted to
uint32_t in argument list. Otherwise, sum size and offset may
overflow uint32_t and don't trigger assert.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Does not solve https://github.com/thesofproject/sof/issues/3423 but
converts a buffer overflow and crash into a more usable assert.
Buffer overflow found by running rimage with valgrind and the binaries
provided by @singalsu
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Checkpatch is a tool which checks patch code style
alignment with Linux kernel code.
By the way print short graphs of used commits, to
show whats under test.
Checkpatch call is precede by `set -x`, to show used
arguments values, especially checked commits range.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
It's encouraged to use version with $(...).
Backtick command substitution `...` is legacy
syntax with several issues.
1. It has a series of undefined behaviors related to quoting in POSIX.
2. It imposes a custom escaping mode with surprising results.
3. It's exceptionally hard to nest.
~https://github.com/koalaman/shellcheck/wiki/SC2006
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Caveat: this was just reported by valgrind. I did not test any actual
toml parsing error either (who tests error handling?) but this code
can't be worse than the previous one.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Passing a 64 bits ELF file by accident (for instance: '/usr/bin/openssl'
while messing up the command line options) caused an interesting cascade
of errors and memory corruption which are all caught in this commit.
This doesn't make rimage fuzz-proof far from it; only fool-proof which
is still useful.
In passing add some quotes so the error message when failing to find the
SHT_NULL section with an empty name is a little bit more readable.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Commit https://github.com/thesofproject/soft/commits/59d81995f6828 added
an -l option (for --liam? :-) which was never implemented. Remove it
because silently discarding user input is really not nice no matter how
wrong it is.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Error codes like ENOKEY and EBADE are not provide for all windows
toolchains, so to immit possible build errors, some more standard
error codes should be used.
Detailed error message is printed in stderr, so end user still
will be well informed about error source.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
It allows to assure right version of chosen headers during
reading logs in verbose mode.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Used platform should be defined by config file, given in
-c option. Double ways of defining platform may lead to
missalignement, so old way should be removed.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>