Skip to contentSkip to conversation

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

PATCH In review OGAWA Hirofumi 2 participants 2 messages Oct 6, 2003 Library code

lore
Share & tools
lore
#0 lore raw

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

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(-)
lib/parser.c renamed from lib/parser.c~parser-zero-string +3 -1
diff -puN lib/parser.c~parser-zero-string lib/parser.c
@@ -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;

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#1 lore raw

On Tue, 07 Oct 2003 01:58:47 +0900 OGAWA Hirofumi <[email protected]> wrote:

| 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?)

I like the check here.

And thanks for doing all of these updates.

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

--
~Randy