From 8f5c232ab629b7aa83c5a1d4eff9648874a0c9ca Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 05 Jul 2007 17:46:46 +0000
Subject: [PATCH] Update all of the command-line tools to ensure that the exit code should always be between 0 and 255, which are the bounds enforced by most shells and operating environments. Any negative value, or any positive value greater than 255 will be changed to 255.
---
opends/src/server/org/opends/server/util/StaticUtils.java | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/StaticUtils.java b/opends/src/server/org/opends/server/util/StaticUtils.java
index 58ffeb1..f9c77f8 100644
--- a/opends/src/server/org/opends/server/util/StaticUtils.java
+++ b/opends/src/server/org/opends/server/util/StaticUtils.java
@@ -3784,5 +3784,36 @@
return buffer.toString();
}
+
+
+
+ /**
+ * Filters the provided value to ensure that it is appropriate for use as an
+ * exit code. Exit code values are generally only allowed to be between 0 and
+ * 255, so any value outside of this range will be converted to 255, which is
+ * the typical exit code used to indicate an overflow value.
+ *
+ * @param exitCode The exit code value to be processed.
+ *
+ * @return An integer value between 0 and 255, inclusive. If the provided
+ * exit code was already between 0 and 255, then the original value
+ * will be returned. If the provided value was out of this range,
+ * then 255 will be returned.
+ */
+ public static int filterExitCode(int exitCode)
+ {
+ if (exitCode < 0)
+ {
+ return 255;
+ }
+ else if (exitCode > 255)
+ {
+ return 255;
+ }
+ else
+ {
+ return exitCode;
+ }
+ }
}
--
Gitblit v1.10.0