From 08e0ed300ad369e0389dfd9335ef6d91b4f8501a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Jun 2023 12:26:46 +0200 Subject: [PATCH] sleep-config: check if we operate on regular file in swap_device_to_device_id() in swap file code path Similar to the previous commit: before we continue doing swap file operations let's ensure this actually is a swap file. --- src/shared/sleep-config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index cee0a69cb0..0db02fae87 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -631,6 +631,10 @@ static int swap_device_to_device_id(const SwapEntry *swap, dev_t *ret_dev) { return 0; } + r = stat_verify_regular(&sb); + if (r < 0) + return r; + return get_block_device(swap->device, ret_dev); }