From 600f6d32b811e6620bda10b244a11192292dbf70 Mon Sep 17 00:00:00 2001 From: Nathan Patrizi Date: Wed, 6 May 2026 20:11:18 +0100 Subject: [PATCH] driver_settings: Allow successful load of empty settings file * Allow load_driver_settings_from_file() to succeed when loading a file with a size of 0. * This fixes scenarios where a watched config file would not apply settings if the file was emptied. * This happens with the network services file if all network services are disabled as it leaves the file empty. This caused issues such as sshd not being stopped when it was the last service disabled. Fixes #17127 #14086 Change-Id: Icb79c80047900abd7756035cb9cf025a36917467 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10945 Haiku-Format: Haiku-format Bot Reviewed-by: waddlesplash --- src/system/libroot/os/driver_settings.cpp | 2 +- src/tools/fs_shell/driver_settings.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/libroot/os/driver_settings.cpp b/src/system/libroot/os/driver_settings.cpp index eecf77dde1..fb066f7f6e 100644 --- a/src/system/libroot/os/driver_settings.cpp +++ b/src/system/libroot/os/driver_settings.cpp @@ -443,7 +443,7 @@ load_driver_settings_from_file(int file, const char *driverName) if (fstat(file, &stat) < B_OK) return NULL; - if (stat.st_size > B_OK && stat.st_size < MAX_SETTINGS_SIZE) { + if (stat.st_size >= 0 && stat.st_size < MAX_SETTINGS_SIZE) { char *text = (char *)malloc(stat.st_size + 1); if (text != NULL && read(file, text, stat.st_size) == stat.st_size) { settings_handle *handle; diff --git a/src/tools/fs_shell/driver_settings.cpp b/src/tools/fs_shell/driver_settings.cpp index 4cbda9abf0..34daf90269 100644 --- a/src/tools/fs_shell/driver_settings.cpp +++ b/src/tools/fs_shell/driver_settings.cpp @@ -409,7 +409,7 @@ load_driver_settings_from_file(int file, const char *driverName) if (fssh_fstat(file, &stat) < FSSH_B_OK) return NULL; - if (stat.fssh_st_size > FSSH_B_OK && stat.fssh_st_size < MAX_SETTINGS_SIZE) { + if (stat.fssh_st_size >= 0 && stat.fssh_st_size < MAX_SETTINGS_SIZE) { char *text = (char *)malloc(stat.fssh_st_size + 1); if (text != NULL && fssh_read(file, text, stat.fssh_st_size) == stat.fssh_st_size) { settings_handle *handle;