Jan Janssen
07d0fde49e
boot: Use char
...
This also switches to _cleanup_free_. Otherwise no code changes.
2022-06-27 12:26:57 +02:00
Jan Janssen
3639d1b021
boot: Use char16_t
...
This also switches to _cleanup_free_. Otherwise no code changes.
2022-06-27 12:26:21 +02:00
Jan Janssen
db4122d130
boot: Use stdint types
2022-06-27 12:16:27 +02:00
Jan Janssen
2a5e4fe414
boot: Remove use of EFI_ERROR
...
The macro is ugly and annoying to use and provides no real benefit. The
only reason to use it would be to allow warnings to go through. But any
EFI APIs we call do not return warning status codes or we do not check
the return value anyway. The only other case would be BS->StartImage,
where we already treat anything other than EFI_SUCCESS as an error
anyway.
This also helps the compiler and code analyzers to better reason about
the code. In particular, this can help reduce use of uninitialized
variable warnings.
2022-06-27 12:16:27 +02:00
Jan Janssen
8599bdb67c
boot: Rename remaining EFI_STATUS vars to err for consistency
2022-06-27 12:16:27 +02:00
Jan Janssen
c4ba5fef78
boot: Fix calls to ResetSystem
...
gnu-efi falsely declares a return type for ResetSystem when it should be
void. The spec also says that it never returns, so just assert.
2022-06-23 18:41:35 +02:00
Jan Janssen
01d81c126b
meson: Reorder cflags for sd-boot
...
Currently, -Wall and -Wextra override previously passed flags like
-Wno-unused-parameter. This reorders them to be passed before any
optional flags. -Wsign-compare is part of -Wextra and therefore dropped.
-nostdlib is a link-stage flag and dropped as it is already part of
efi_ldflags.
2022-06-17 12:57:41 +09:00
Yu Watanabe
288bafa952
Merge pull request #23691 from medhefgo/efi-clang
...
efi: Add parse_number8/16
2022-06-11 05:01:24 +09:00
Yu Watanabe
3e808e0769
Merge pull request #23701 from medhefgo/boot-mem
...
boot: Use memcpy/memset provided by firmware
2022-06-11 04:29:27 +09:00
Shreenidhi Shedi
1dea9f1268
boot: use efi_memcpy inplace of memcpy
...
`efi_memcpy` does some validations before referencing pointers, it is
the safer option for this case.
Fixes: CID#1489876
2022-06-11 04:25:35 +09:00
Jan Janssen
8494bd1ced
boot: Use memcpy/memset provided by firmware
...
These are significantly faster and safe us from rolling our own
optimized versions.
2022-06-10 15:54:06 +02:00
Jan Janssen
2b0af8e76a
boot: Mark memcmp/memcpy/memset aliases as used
...
The compiler may emit calls to these but also optimize the function away
somehow, breaking at link stage. Marking them as used prevents this.
2022-06-10 15:54:02 +02:00
Jan Janssen
f23b2a04e6
efi-string: Remove one more |= for bool
...
This one was missed in #23589 .
2022-06-10 14:14:57 +02:00
Jan Janssen
153381952b
boot: Use parse_number16 for boot counter parsing
2022-06-10 11:50:13 +02:00
Jan Janssen
1621ab4600
boot: Drop use of Atoi
2022-06-10 11:50:13 +02:00
Jan Janssen
72bd3458e5
boot: Add parse_number8/16
2022-06-10 11:50:13 +02:00
Yu Watanabe
da5fb1877d
boot/efi-string: check the end of haystack before testing remaining pattern
...
Fixes buffer-overflow reported at https://github.com/systemd/systemd/pull/23589#issuecomment-1151820341 .
2022-06-10 12:05:38 +09:00
Jan Janssen
55233913c8
boot: Drop use of DuplicateDevicePath
2022-06-09 12:50:13 +02:00
Jan Janssen
e17fd5538f
boot: Don't copy device path
...
BS->LocateDevicePath only advances the passed device path pointer.
It does not actually modify it, so there is no need to make a copy.
2022-06-09 12:50:13 +02:00
Jan Janssen
b05d69ed72
boot: Drop use of LibLocateHandle
2022-06-09 12:50:13 +02:00
Jan Janssen
b04f818417
boot: Drop use of UnpackDevicePath
...
Device paths are a packed data structure and the UEFI spec is clear that
members may be misaligned.
In this case all accesses are aligned except for the signature. We can
simply memcpy it instead of making a whole (aligned) copy of the device
path.
2022-06-09 12:50:13 +02:00
Jan Janssen
79a2b916a0
boot: Drop use of FileDevicePath
2022-06-09 12:50:13 +02:00
Jan Janssen
0af26643d0
boot: Use xmalloc
...
This drops the unused xnew0 and xallocate_zero_pool as there is only two
users of it. _cleanup_freepool_ will be phased out once the types in the
declarations are changed/renamed.
2022-06-09 12:50:13 +02:00
Jan Janssen
9148312fab
boot: Add xmalloc
2022-06-09 12:50:13 +02:00
Jan Janssen
5594ebee99
boot: Drop use of DevicePathFromHandle
2022-06-09 12:50:13 +02:00
Jan Janssen
6a261332bc
boot: Drop use of LibLocateProtocol
2022-06-09 12:50:13 +02:00
Jan Janssen
f747ca3ec3
boot: Drop use of LibOpenRoot
2022-06-09 12:50:13 +02:00
Jan Janssen
7ebce8145e
boot: Drop use of LibGetSystemConfigurationTable
2022-06-09 12:50:13 +02:00
Jan Janssen
23742af522
boot: Drop use of MetaiMatch
...
A future commit will add support for unicode collation protocol that
allows case folding and comparing strings with locale awareness. But it
only operates on whole strings, so fnmatch cannot use those without a
heavy cost. Instead we just case fold the patterns instead (the IDs we
try to match are already lower case).
2022-06-09 12:50:13 +02:00
Jan Janssen
0e8ecba96e
boot: Add efi_fnmatch
...
Unlike MetaiMatch from the UEFI spec/EDK2 this implementation is
intended to be compatible with POSIX fnmatch.
2022-06-09 12:50:08 +02:00
Zbigniew Jędrzejewski-Szmek
da60e5b5c7
bootctl: inline iterator variable
2022-06-07 15:17:06 +02:00
Yu Watanabe
095e173a04
boot: use CMP() macro for safety
2022-06-03 04:20:46 +09:00
Yu Watanabe
42e785d096
boot: make several functions inline
...
Follow-ups for #23512 .
2022-06-03 04:20:46 +09:00
Yu Watanabe
a54e635d02
boot: fix typo
2022-06-03 04:20:46 +09:00
Yu Watanabe
9db25d01ef
Merge pull request #23531 from yuwata/sd-bus-drop-version-2
...
sd-bus: drop version 2 format support
2022-06-01 14:51:44 +09:00
Yu Watanabe
b4e7df4a47
boot: use ALIGN4()
2022-06-01 03:41:15 +09:00
Jan Janssen
7783ab5df1
boot: Use xstrdup8/16
...
Note that xstrdup is now safe to call with a NULL pointer and will
just return NULL in that case.
2022-05-31 15:15:01 +02:00
Jan Janssen
101f68ff33
boot: Add xstrdup8/16
2022-05-31 15:15:01 +02:00
Jan Janssen
bbc1f2eac5
boot: Use memcmp/memcpy/memset
2022-05-31 15:15:01 +02:00
Jan Janssen
f7967716e3
boot: Add memcmp/memcpy/memset
2022-05-31 15:14:56 +02:00
Jan Janssen
60c2af56d6
boot: Use strsize8/16
2022-05-31 15:14:56 +02:00
Jan Janssen
96dc0dd387
boot: Add strsize8/16
2022-05-31 15:14:54 +02:00
Jan Janssen
fb67588c62
boot: Use strchr8/16
2022-05-31 15:13:58 +02:00
Jan Janssen
5d7e0e8341
boot: Add strchr8/16
2022-05-31 15:13:58 +02:00
Jan Janssen
08ed842b56
boot: Use strcpy8/16
2022-05-31 15:10:48 +02:00
Jan Janssen
ef4d71ad7f
boot: Add strcpy8/16
2022-05-31 15:10:48 +02:00
Jan Janssen
fc178cf1f8
boot: Use strtolower8/16
2022-05-31 15:10:48 +02:00
Jan Janssen
98850528bf
boot: Add strtolower8/16
2022-05-31 15:10:45 +02:00
Jan Janssen
3d5127c68f
boot: Use strcmp16 for cpio sorting
2022-05-31 15:09:10 +02:00
Jan Janssen
ec436bdf16
boot: Use strcmp8/16
...
This also replaces streq and similar functions for consistency. Note
that streq16 is null pointer safe, so streq_ptr can be safely replaced
too.
2022-05-31 15:09:10 +02:00