This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Fix NPE in input parser.


The branch, master has been updated
       via  4581f27bd20fc5b8f30e181ec4e0d22af79f510b (commit)
      from  031d8a4db7053c83ff030b44732c545ac0fb4a7c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 4581f27bd20fc5b8f30e181ec4e0d22af79f510b
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Dec 10 15:08:21 2007 -0500

    Fix NPE in input parser.
    
    frysk-core/frysk/hpd/ChangeLog
    2007-12-10  Andrew Cagney  <cagney@redhat.com>
    
    	* TestInput.java (check): Check out-of-range requests.
    	* Input.java (parameter(int)): Fix off-by-one check of
    	upper-bound.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog      |    4 ++++
 frysk-core/frysk/hpd/Input.java     |    2 +-
 frysk-core/frysk/hpd/TestInput.java |   13 +++++++++----
 3 files changed, 14 insertions(+), 5 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 137b5ea..5d2b6e7 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,5 +1,9 @@
 2007-12-10  Andrew Cagney  <cagney@redhat.com>
 
+	* TestInput.java (check): Check out-of-range requests.
+	* Input.java (parameter(int)): Fix off-by-one check of
+	upper-bound.
+
 	* TestEvalCommands.java (testFormatInteger_b()): Replace
 	testFormatInteger_t().
 	* CommandOption.java (FormatOption.parse(String,Object)): Change
diff --git a/frysk-core/frysk/hpd/Input.java b/frysk-core/frysk/hpd/Input.java
index 80317c7..c47f68b 100644
--- a/frysk-core/frysk/hpd/Input.java
+++ b/frysk-core/frysk/hpd/Input.java
@@ -120,7 +120,7 @@ class Input {
      * Return the N'th parameter.
      */
     String parameter(int n) {
-	if (n < 0 || n > size())
+	if (n < 0 || n >= size())
 	    return null;
 	else
 	    return token(n).value;
diff --git a/frysk-core/frysk/hpd/TestInput.java b/frysk-core/frysk/hpd/TestInput.java
index 1f0cc6f..4288fd1 100644
--- a/frysk-core/frysk/hpd/TestInput.java
+++ b/frysk-core/frysk/hpd/TestInput.java
@@ -54,15 +54,20 @@ public class TestInput extends TestLib {
 	assertEquals("set", set, input.getSet());
 	assertEquals("stringArrayValue", results, input.stringArrayValue());
 	for (int i = 0; i < results.length; i++) {
-	    assertEquals("parameter " + i,
-			 i == results.length ? null : results[i],
+	    assertEquals("parameter " + i, results[i],
 			 input.parameter(i));
-	    assertEquals("value " + i,
-			 i == results.length ? null : results[i],
+	    assertEquals("value " + i, results[i],
 			 input.token(i).value);
 	    assertEquals("start " + i, starts[i], input.token(i).start);
 	    assertEquals("end " + i, ends[i], input.token(i).end);
 	}
+	// When out-of-bounds, NULL is returned.
+	assertEquals("parameter -1", null, input.parameter(-1));
+	assertEquals("value -1", null, input.token(-1));
+	assertEquals("parameter " + results.length, null,
+		     input.parameter(results.length));
+	assertEquals("value " + results.length, null,
+		     input.token(results.length));
     }
 
     private void check(Input input, String[] results) {


hooks/post-receive
--
frysk system monitor/debugger


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]