From 2b2459419d3ad87176dd0c387a2e8a4f9112f5a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Thu, 4 Nov 1999 12:25:20 -0800
Subject: [PATCH] bugfix for \0 in %{ %} (sscanf)

Rev: src/opcodes.c:1.65
Rev: src/testsuite.in:1.223
---
 src/opcodes.c    | 4 ++--
 src/testsuite.in | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/opcodes.c b/src/opcodes.c
index 2415f942d7..09d63e1e81 100644
--- a/src/opcodes.c
+++ b/src/opcodes.c
@@ -25,7 +25,7 @@
 #include "security.h"
 #include "bignum.h"
 
-RCSID("$Id: opcodes.c,v 1.64 1999/11/04 20:04:05 hubbe Exp $");
+RCSID("$Id: opcodes.c,v 1.65 1999/11/04 20:25:18 hubbe Exp $");
 
 void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind)
 {
@@ -1040,7 +1040,7 @@ static INT32 PIKE_CONCAT4(very_low_sscanf_,INPUT_SHIFT,_,MATCH_SHIFT)(	 \
 	  long tmp;							 \
 	  for(e=cnt+1,tmp=1;tmp;e++)					 \
 	  {								 \
-	    if(!match[e])						 \
+	    if(e>=match_len)						 \
 	    {								 \
 	      error("Missing %%} in format string.\n");			 \
 	      break;		/* UNREACHED */				 \
diff --git a/src/testsuite.in b/src/testsuite.in
index f30df2d8a5..1c16030857 100644
--- a/src/testsuite.in
+++ b/src/testsuite.in
@@ -1,4 +1,4 @@
-test_true([["$Id: testsuite.in,v 1.222 1999/11/04 20:04:07 hubbe Exp $"]])
+test_true([["$Id: testsuite.in,v 1.223 1999/11/04 20:25:20 hubbe Exp $"]])
 
 cond([[all_constants()->_verify_internals]],
 [[
@@ -1774,6 +1774,9 @@ test_equal([[array_sscanf("foo\1000\1001\1111\1110\2000","%s%[\1000-\1111]%s")]]
 
 test_equal([[array_sscanf("\2000\1000\1111\1001\1110foo","%s%[\1000-\1111]%s")]],
 	[[ ({  "\2000", "\1000\1111\1001\1110", "foo"}) ]])
+
+test_equal([[ array_sscanf("02 00 DC 00 0B","%{%x%*[\0-/:-@]%}")[0] ]],
+    [[ ({ ({2}), ({0}), ({220}),({0}), ({11}) }) ]])
 	
 
 // Basics
-- 
GitLab