diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-10-18 19:57:06 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-10-18 22:44:16 +0200 |
commit | 892eb4d7958c97f1a0678535c95f1ca84d9ebe9e (patch) | |
tree | 2b493bdcf830533a1c9d7af850ccc0c241edcac1 /src/shared/serialize.c | |
parent | test: add a fuzzer for exec_{serialize,deserialize}_invocation() (diff) | |
download | systemd-892eb4d7958c97f1a0678535c95f1ca84d9ebe9e.tar.xz systemd-892eb4d7958c97f1a0678535c95f1ca84d9ebe9e.zip |
core: don't assert when serializing malformed state
Diffstat (limited to 'src/shared/serialize.c')
-rw-r--r-- | src/shared/serialize.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/shared/serialize.c b/src/shared/serialize.c index cb1255932b..5019dbf181 100644 --- a/src/shared/serialize.c +++ b/src/shared/serialize.c @@ -207,7 +207,9 @@ int serialize_item_hexmem(FILE *f, const char *key, const void *p, size_t l) { assert(f); assert(key); - assert(p || l == 0); + + if (!p && l > 0) + return -EINVAL; if (l == 0) return 0; @@ -230,7 +232,9 @@ int serialize_item_base64mem(FILE *f, const char *key, const void *p, size_t l) assert(f); assert(key); - assert(p || l == 0); + + if (!p && l > 0) + return -EINVAL; if (l == 0) return 0; |