The intent here seems to have been to ignore lines with too few
arguments to be valid, but since strtok() returns NULL at the end of the
string, if you only have "verb noun", you'd be falsely rejected.

Since we've kept a count anyway, just check the count.
---
 toys/pending/modprobe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
From 09d86b11a398f4e073045fd213f53a91107d4b52 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Thu, 3 Jun 2021 15:15:57 -0700
Subject: [PATCH] modprobe: fix parsing of short lines.

The intent here seems to have been to ignore lines with too few
arguments to be valid, but since strtok() returns NULL at the end of the
string, if you only have "verb noun", you'd be falsely rejected.

Since we've kept a count anyway, just check the count.
---
 toys/pending/modprobe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c
index f1c4338e..a3f5bb9e 100644
--- a/toys/pending/modprobe.c
+++ b/toys/pending/modprobe.c
@@ -238,7 +238,8 @@ static int config_action(struct dirtree *node)
         break;
       }
     }
-    if (!tk) continue; 
+    // Every command requires at least one argument.
+    if (tcount < 2) continue;
     // process the tokens[0] contains first word of config line.
     if (!strcmp(tokens[0], "alias")) {
       struct arg_list *temp;
-- 
2.32.0.rc1.229.g3e70b5a671-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to