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 <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Nathan Patrizi
2026-05-07 07:23:12 +00:00
committed by Adrien Destugues
parent 8e37e00684
commit 600f6d32b8
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;