{"record":{"id":"b91442d71a27ab0e","repo":"NationalSecurityAgency/ghidra","slug":"negative-value-not-permitted-for-b91442","errorCode":null,"errorMessage":"Negative value not permitted for {}","messagePattern":"Negative value not permitted for (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java","lineNumber":375,"sourceCode":"\t\tif (params.length <= index) {\n\t\t\tthrow new IllegalArgumentException(\"Missing required parameter: \" + name);\n\t\t}\n\t\tString p = params[index];\n\t\tif (p.startsWith(\"--\") || p.contains(\"=\")) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Missing required parameter (\" + name + \") before specified option: \" + p);\n\t\t}\n\t}\n\n\tprivate Integer parsePositiveIntegerOption(String option) {\n\t\tString optionValue = optionValueMap.get(option);\n\t\tif (optionValue == null) {\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tint value = Integer.valueOf(optionValue);\n\t\t\tif (value < 0) {\n\t\t\t\tthrow new IllegalArgumentException(\"Negative value not permitted for \" + option);\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\t\tcatch (NumberFormatException e) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid integer value specified for \" + option);\n\t\t}\n\t}\n\n\t/**\n\t * Runs the command specified by the given set of params.\n\t * \n\t * @param params the parameters specifying the command\n\t * @param monitor the task monitor\n\t * @throws IllegalArgumentException if invalid params have been specified\n\t * @throws Exception if there's an error during the operation\n\t * @throws CancelledException if processing is cancelled\n\t */\n\tpublic void run(String[] params, TaskMonitor monitor) throws Exception, CancelledException {","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java#L357-L393","documentation":"Thrown by parsePositiveIntegerOption() when a numeric option value successfully parses as an integer but is negative (value < 0). Options parsed by this method include --limit, --maxfunc, and similar numeric configuration values that must be non-negative.","triggerScenarios":"Specifying a negative value for a numeric option, e.g., '--limit -5' or '--maxfunc=-10'. The value parses as a valid integer but fails the >= 0 check.","commonSituations":"Using a negative sentinel value (common in some CLI conventions); a variable or script that computes the limit producing a negative result; misunderstanding the valid range.","solutions":["Use a non-negative integer value for the option.","If the intent is 'unlimited', check whether the option accepts a special value or can be omitted entirely.","Validate computed values in scripts before passing them to BSim."],"exampleFix":"// before\nbsim listexes h2://localhost/db --limit -1\n// error: Negative value not permitted for --limit\n\n// after\nbsim listexes h2://localhost/db --limit 100","handlingStrategy":"validation","validationCode":"String limitStr = optionValueMap.get(\"--limit\");\nif (limitStr != null) {\n    int val = Integer.parseInt(limitStr);\n    if (val < 0) {\n        throw new IllegalArgumentException(\"--limit must be non-negative, got: \" + val);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use non-negative integers for numeric options like --limit and --maxfunc.","Validate computed numeric values in scripts before passing them to BSim.","Omit the option entirely if you want the default value rather than passing a negative sentinel."],"tags":["bsim","ghidra","command-line","argument-parsing","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}