Use find_str_at_start_of_line(), not strstr() here: we don't want
to match "MemTotal: " if it appears in the middle of a line.
Fixes #40315; bugfix on 0.2.5.4-alpha.
--- /dev/null
+ o Minor bugfixes (Linux, relay):
+ - Fix a bug in determining total available system memory that would have
+ been triggered if the format of /proc/meminfo had ever changed
+ to include "MemTotal:" in the middle of a line. Fixes bug 40315;
+ bugfix on 0.2.5.4-alpha.
lib/log/*.h
lib/malloc/*.h
lib/meminfo/*.h
+lib/string/*.h
lib/testsupport/*.h
#include "lib/fs/files.h"
#include "lib/log/log.h"
#include "lib/malloc/malloc.h"
+#include "lib/string/util_string.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
s = read_file_to_str_until_eof(fd, 65536, &file_size);
if (!s)
goto err;
- cp = strstr(s, "MemTotal:");
+ cp = find_str_at_start_of_line(s, "MemTotal:");
if (!cp)
goto err;
/* Use the system sscanf so that space will match a wider number of space */