NationalSecurityAgency/ghidra · error · IllegalArgumentException
Negative value not permitted for {}
Error message
Negative value not permitted for {} What it means
Thrown by parsePositiveIntegerOption when an integer option (e.g. --port) parses successfully via Integer.valueOf but the result is less than zero. The guard explicitly rejects negative values.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:370
}
}
private void checkRequiredParam(String[] params, int index, String name) {
if (params.length <= index) {
throw new IllegalArgumentException("Missing required parameter: " + name);
}
String p = params[index];
if (p.startsWith("--")) {
throw new IllegalArgumentException(
"Missing required parameter (" + name + ") before specified option: " + p);
}
}
private int parsePositiveIntegerOption(String option, String optionValue) {
try {
int value = Integer.valueOf(optionValue);
if (value < 0) {
throw new IllegalArgumentException("Negative value not permitted for " + option);
}
return value;
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid integer value specified for " + option);
}
}
/**
* Verify that the given file is a PEM certificate
* @param testFile the file to test
* @return true if testFile looks like a PEM certificate
* @throws IOException if there is a problem reading the given file
*/
private static boolean verifyPEMFormat(File testFile) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(testFile));
try {
// All we currently do is search for the certificate header in the first 200 linesView on GitHub (pinned to d5f144c24d)
Solutions
- Use a non-negative integer (the check allows 0 despite the method name).
- For ports prefer 1024–65535; verify the source of the value.
- Strip any stray minus sign from computed values before passing them.
Example fix
// before bsim control configure host --port -5 // after bsim control configure host --port 5432
Defensive patterns
Strategy: validation
Validate before calling
// Reject negative integers for port-like options before launch.
try {
int v = Integer.parseInt(portValue);
if (v < 0) {
System.err.println("Negative value not allowed: " + v);
return;
}
} catch (NumberFormatException ignored) {
System.err.println("Not an integer: " + portValue);
} Try / catch
try {
launchable.parsePositiveIntegerOption(option, value);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Negative value not permitted")) {
System.err.println("Use a non-negative integer for " + option);
}
throw e;
} Prevention
- Bound-check integers (>= 0, or a sensible port range) before passing them.
- Strip accidental minus signs from computed values.
- Note the tool allows 0 despite the method name 'Positive'.
When it happens
Trigger: Passing a negative integer such as `--port -1` or `--port -5`, which Integer.valueOf accepts but fails the `value < 0` check at line 370.
Common situations: Accidental leading minus, a signed value sourced from a variable/macro, or an off-by-one producing -1.
Related errors
- Unknown command: {}
- Unsupported command: {}
- Unsupported option use: {}
- Unexpected argument: {}
- Unsupported option specification: {}=
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/eb2a7cad2d46738b.
Report an issue: GitHub.