diff --git a/src/mbpfan.c b/src/mbpfan.c
index 62d9dbe..15cb1c5 100644
--- a/src/mbpfan.c
+++ b/src/mbpfan.c
@@ -230,6 +230,7 @@ t_sensors *retrieve_sensors()
free(s);
exit(EXIT_FAILURE);
}
+ /* fail-safe, a garbage value leaves fans at full until the first poll */
s->temperature = max_temp;
if (fscanf(file, "%u", &s->temperature) != 1) {
mbp_log(LOG_WARNING, "Could not parse initial sensor value at %s", path);
diff --git a/src/settings.c b/src/settings.c
index b89c143..2ea19db 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -605,6 +605,7 @@ static int get_key_value_from_str(const char *str, char *out_buf1, unsigned int
count1 = 0;
count2 = 0;
+ char *out_buf1_begin = out_buf1;
/* Read the key value from the input string and write it sequentially
* to the first output buffer by walking the input string until we either hit
@@ -631,7 +632,7 @@ static int get_key_value_from_str(const char *str, char *out_buf1, unsigned int
*out_buf1 = '\0';
/* Now trace the first input buffer backwards until we hit a non-blank character */
- while (is_blank_char(*(out_buf1 - 1))) {
+ while (out_buf1 > out_buf1_begin && is_blank_char(*(out_buf1 - 1))) {
out_buf1--;
}
clarity comment on mbpfan.c, OOB r/w guard in settings.c
05067e213e33aa97c0dcca6bde8b9c908e9c28e0
cjosie <administrator@josie-c.com> · 2026-11-16T17:07 ·
browse files at this commit
parents:
0ed9079