Commit Graph

26 Commits

Author SHA1 Message Date
Mike Yuan
47941afd17 basic/memory-util: make mempcpy_typesafe() take number of obj rather than raw size
Follow-up for eda6223942
2024-09-20 22:44:34 +02:00
Mike Yuan
eda6223942 basic/memory-util: introduce mempcpy_typesafe 2024-09-20 08:29:35 +09:00
Vladimir Stoiakin
85686b37b0 cryptenroll: allow to use a public key on a token
This patch allows systemd-cryptenroll to enroll directly with a public key if a certificate is missing on a token.

Fixes: #30675
2024-02-03 03:00:51 +09:00
Yu Watanabe
2977904cad macro: introduce several helper functions for alignment
Some of them are not used in this commit, but will be used later.
2023-10-19 18:31:44 +09:00
Luca Boccassi
3b66a6764e Move CLEANUP_ARRAY to src/fundamental 2023-10-09 22:22:09 +01:00
Lennart Poettering
4ac79c2b77 memory-util: move memzero() to src/fundamental/ to share with UEFI
(and while we are at it, make sure it returns the input pointer as
output)
2023-10-02 15:00:13 +02:00
Yu Watanabe
3facdc7da8 memory-util: make ArrayCleanup passed to array_cleanup() const
Should not change any behavior, preparation for later commits.
2023-05-09 17:53:42 +09:00
Lennart Poettering
ff3f1464ec memory-util: add a concept for gcc cleanup attribute based array destruction 2023-02-23 11:43:43 +09:00
Jan Janssen
3f92dc2fd4 boot: Simplify object erasure
This erase_obj() machinery looks like voodoo and creates an awful lot of
noise as soon as we get back to building with -O0. We can do this in a
more simple way by introducing a struct that holds the information we
need on cleanup. When building with optimization enabled, all this gets
inlined and the eraser vanishes.
2023-01-09 18:58:54 +01:00
Yu Watanabe
507cd76085 memory-util: introdyce mempcpy_safe() 2022-02-16 16:23:58 +09:00
Lennart Poettering
3f9992d82e memory-util: replace memeqzero() by a more generic memeqbyte()
The new helper can check for any byte, no just zeroes. The old name is
then converted into a macro that wraps our new version of the helper.
2021-09-13 12:48:27 +02:00
Lennart Poettering
d8782cc5c2 memory-util: add mempmem_safe()
This is like memmem_safe() but returns a pointer after the needle,
instead to the beginning of the needle.

This is then used at one place. Not much, but it makes me sleep safer at
night, as it avoids the manual counting done so far.
2021-08-10 14:55:50 +02:00
Lennart Poettering
2adcf6f4f7 Merge pull request #19662 from yuwata/memdup
util: make memdup() or friends safer
2021-05-19 23:24:55 +02:00
Lennart Poettering
6df28e1f84 alloc-util: introduce MALLOC_SIZEOF_SAFE() helper
It's a wrapper around malloc_usable_size() that is supposed to be
compatible with _FORTIFY_SOURCES=1, by taking the
__builtin_object_size() data into account, the same way as the
_FORTIFY_SOURCES=1 logic does.

Fixes: #19203
2021-05-19 16:42:00 +02:00
Yu Watanabe
d1f3b08098 memory-util: make memcpy_safe() return pointer to destination 2021-05-19 21:20:49 +09:00
Yu Watanabe
db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek
b98f393d88 bus-message: add macro for calculation of offset from the page 2020-06-22 17:18:35 +02:00
Lennart Poettering
13933c6b6f memory-util: add missing () in macro evaulation 2020-04-23 12:12:45 +02:00
Frantisek Sumsal
e514aa1eea tree-wide: yet another batch of coccinelle recommendations
Prettify certain parts of the codebase using coccinelle transformations
(no functional changes).
2020-01-02 13:32:55 +01:00
Lennart Poettering
282bde1066 memory-util: introduce erase_and_free() helper 2019-12-04 10:57:59 +01:00
Chris Down
3a6da69a93 memory-util: Add PAGE_ALIGN_DOWN
For example, cgroup v2 rounds down to the previous page when returning
memory limits.
2019-10-03 14:43:30 +01:00
Zbigniew Jędrzejewski-Szmek
44c786f04a test: add _cleanup_(erase_and_freep)
Based on the macro and test case by Lennart Poettering and
Topi Miettinen suggestion.
2019-07-10 11:39:03 +02:00
Zbigniew Jędrzejewski-Szmek
3135369cff basic/memory-util: do not "return" anything from memzero() macro
The macro is not used in expressions, so we don't need the ternary statement.
2019-05-30 22:55:32 +02:00
Lennart Poettering
e1ed99c8c8 ask-password: erase character read with _cleanup_
This is much nicer, since it means we erase the character regardless how
we exit the scope.
2019-03-20 10:48:33 +01:00
Lennart Poettering
090a9c1eba util: move some raw memory functions from string-util.h → memory-util.h 2019-03-14 13:25:51 +01:00
Lennart Poettering
0a9707187b util: split out memcmp()/memset() related calls into memory-util.[ch]
Just some source rearranging.
2019-03-13 12:16:43 +01:00