]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] lib/parser: Not recognize nul string as "%s" (6/6)
authorHirofumi Ogawa <hirofumi@mail.parknet.co.jp>
Mon, 6 Oct 2003 04:02:22 +0000 (21:02 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 6 Oct 2003 04:02:22 +0000 (21:02 -0700)
Current match_token recognize "foo=" as "foo=%s". So this change the
nul string does not recognize as "%s".

lib/parser.c

index 858061397fe2b53db7231f5c9546892c2aa2b27f..790ec2a858d7e8b08a2d85dbcb767a4c78735a5c 100644 (file)
@@ -45,7 +45,9 @@ static int match_one(char *s, char *p, substring_t args[])
                args[argc].from = s;
                switch (*p++) {
                case 's':
-                       if (len == -1 || len > strlen(s))
+                       if (strlen(s) == 0)
+                               return 0;
+                       else if (len == -1 || len > strlen(s))
                                len = strlen(s);
                        args[argc].to = s + len;
                        break;