public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Fix NPE in input parser. Date: Mon, 10 Dec 2007 20:09:00 -0000 [thread overview] Message-ID: <20071210200916.2019.qmail@sourceware.org> (raw) 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
reply other threads:[~2007-12-10 20:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20071210200916.2019.qmail@sourceware.org \ --to=cagney@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).