[PATCH] lib/parser: Not recognize nul string as "%s" (6/6)

From: OGAWA Hirofumi
Date: Mon Oct 06 2003 - 12:03:35 EST


Hi,

Current match_token recognize "foo=" as "foo=%s". So this change the
nul string does not recognize as "%s".

(Umm... this should be check by caller?)



linux-2.6.0-test6-hirofumi/lib/parser.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletion(-)

diff -puN lib/parser.c~parser-zero-string lib/parser.c
--- linux-2.6.0-test6/lib/parser.c~parser-zero-string 2003-10-07 01:51:51.000000000 +0900
+++ linux-2.6.0-test6-hirofumi/lib/parser.c 2003-10-07 01:51:51.000000000 +0900
@@ -45,7 +45,9 @@ static int match_one(char *s, char *p, s
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;

_

--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/