From 267a1a572d8780c11b63fb8640e4c3752ce7f1a1 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 14 May 2021 09:07:07 -0700 Subject: modprobe: don't stop on empty lines. I don't _think_ that can happen with the .dep files since they're machine-generated, but the config files can and do contain empty lines to aid readability. (Not found on Android, so I haven't tested this, but the code already even contained a special case for empty lines. I haven't touched the /proc/modules loop because the kernel definitely isn't going to insert empty lines, and that code _would_ need to be modified to cope with empty lines, and since I can't test this, that would be not just pointless but also irresponsible!) --- toys/pending/modprobe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toys') diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c index 7424e7c0..f1c4338e 100644 --- a/toys/pending/modprobe.c +++ b/toys/pending/modprobe.c @@ -224,7 +224,7 @@ static int config_action(struct dirtree *node) free(filename); return 0; } - for (line = linecp = NULL; read_line(fc, &line) > 0; + for (line = linecp = NULL; read_line(fc, &line) >= 0; free(line), free(linecp), line = linecp = NULL) { char *tk = NULL; @@ -286,7 +286,7 @@ static int depmode_read_entry(char *cmdname) int ret = -1; FILE *fe = xfopen("modules.dep", "r"); - while (read_line(fe, &line) > 0) { + while (read_line(fe, &line) >= 0) { char *tmp = strchr(line, ':'); if (tmp) { @@ -314,7 +314,7 @@ static void find_dep(void) struct module_s *mod; FILE *fe = xfopen("modules.dep", "r"); - for (; read_line(fe, &line) > 0; free(line)) { + for (; read_line(fe, &line) >= 0; free(line)) { char *tmp = strchr(line, ':'); if (tmp) { -- cgit v1.2.3